发表于: 2017-12-26 19:16:51
1 593
今日完成:
写了拦截器,和前端交流数据怎么传,发现很多接口其实不能用。
明日计划:
写接口。
遇到的困难:
不知道怎么传对象数组,只会传 单对象,但是在这个项目中的新增更新角色模块是需要提交角色对象,和模块对象的(这个角色拥有的权限),一个角色拥有的模块不只一个所以要传数组,但是数组对象不知道怎么穿,只会传数组,比如ids=1&ids=2&ids=3&ids=4,这样能得到一个ids[]的数组,啊啊啊啊啊啊啊啊好难啊。这里面想传moduleList,代表对象数组,应该怎么传??
因为模块管理中所有都需要登陆才能操作,只有登陆不需要拦截器,但是我以前的拦截器只能拦截一个固定的url,百度了除了特殊url其他都拦截,但是他的算法我看不懂。
String requestUri = request.getRequestURI();
if(requestUri.startsWith(request.getContextPath())){
requestUri = requestUri.substring(request.getContextPath().length(), requestUri.length());
}
//系统根目录
if (StringUtils.equals("/",requestUri)) {
return true;
}
//放行exceptUrls中配置的url
for (String url:exceptUrls) {
if(url.endsWith("/**")){
if (requestUri.startsWith(url.substring(0, url.length() - 3))) {
return true;
}
} else if (requestUri.startsWith(url)) {
return true;
}
}
mvc配置文件:
<mvc:interceptors>
<!-- 使用bean定义一个Interceptor,直接定义在mvc:interceptors根下面的Interceptor将拦截所有的请求 -->
<!--<bean class="com.ptteng.carrots.youneedboy.interceptor.UserInterceptor"/>-->
<mvc:interceptor>
<mvc:mapping path="/**"/>
<!-- 定义在mvc:interceptor下面的表示是对特定的请求才进行拦截的 -->
<bean class="com.ptteng.carrots.youneedboy.interceptor.UserInterceptor">
<property name="exceptUrls">
<list>
<value>/a/user/login</value>
</list>
</property>
</bean>
</mvc:interceptor>
</mvc:interceptors>
进度:
写接口中。
禅道:
http://task.ptteng.com/zentao/project-task-494.html
评论