springmvc的拦截器,怎么设置不拦截的url
1个回答
展开全部
这是我的拦截器
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/*/*.do" />
<bean class="com.cdxt.card.interceptor.SessionTimeoutInterceptor">
<property name="allowUrls">
<list>
<value>/yhxx/login.do</value>
<value>/yhxx/toLogin.do</value>
<value>/yhxx/sessionTimeOut.do</value>
</list>
</property>
</bean>
</mvc:interceptor>
</mvc:interceptors>
其中allowUrls就是不拦截的
在拦截器中
private List<String> allowUrls;
public List<String> getAllowUrls() {
return allowUrls;
}
public void setAllowUrls(List<String> allowUrls) {
this.allowUrls = allowUrls;
}
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
String requestUri = request.getRequestURI();
for (String url : allowUrls) {
if (requestUri.endsWith(url)) {
return true;
}
}
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/*/*.do" />
<bean class="com.cdxt.card.interceptor.SessionTimeoutInterceptor">
<property name="allowUrls">
<list>
<value>/yhxx/login.do</value>
<value>/yhxx/toLogin.do</value>
<value>/yhxx/sessionTimeOut.do</value>
</list>
</property>
</bean>
</mvc:interceptor>
</mvc:interceptors>
其中allowUrls就是不拦截的
在拦截器中
private List<String> allowUrls;
public List<String> getAllowUrls() {
return allowUrls;
}
public void setAllowUrls(List<String> allowUrls) {
this.allowUrls = allowUrls;
}
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
String requestUri = request.getRequestURI();
for (String url : allowUrls) {
if (requestUri.endsWith(url)) {
return true;
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询