Spring3中的mvc:interceptors标签配置拦截器
来源:互联网 发布:冰毒在淘宝上叫什么 编辑:程序博客网 时间:2024/06/05 07:50
mvc:interceptors
这个标签用于注册一个自定义拦截器或者是WebRequestInterceptors.
可以通过定义URL来进行路径请求拦截,可以做到较为细粒度的拦截控制。
例如在配置文件加入
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 以下配置将拦截所有的URL请求 -->
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<!-- 以下配置将拦截特有的URL请求 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/secure/*"/>
<bean class="org.example.SecurityInterceptor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/admin/*.do"/>
<bean class="org.example.admin.ControlInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>
定义的拦截器只需要实现@Override
public boolean preHandle(HttpServletRequest req,HttpServletResponse res, Object handler)
这个标签用于注册一个自定义拦截器或者是WebRequestInterceptors.
可以通过定义URL来进行路径请求拦截,可以做到较为细粒度的拦截控制。
例如在配置文件加入
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- 以下配置将拦截所有的URL请求 -->
<mvc:interceptors>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<!-- 以下配置将拦截特有的URL请求 -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/secure/*"/>
<bean class="org.example.SecurityInterceptor" />
</mvc:interceptor>
<mvc:interceptor>
<mvc:mapping path="/admin/*.do"/>
<bean class="org.example.admin.ControlInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
</beans>
定义的拦截器只需要实现@Override
public boolean preHandle(HttpServletRequest req,HttpServletResponse res, Object handler)
- Spring3中的mvc:interceptors标签配置拦截器
- Spring3中的mvc:interceptors标签配置拦截器
- Spring3中的mvc:interceptors标签配置拦截器
- Spring3中的mvc:interceptors标签配置拦截器
- Spring3中的mvc:interceptors标签配置拦截器
- mvc:interceptors拦截器配置
- 使用mvc:interceptors标签来声明需要加入到SpringMVC拦截器链中的拦截器
- Spring3参考手册 mvc:interceptors
- Spring MVC 之 Interceptors拦截器
- Spring3 MVC 拦截器
- Spring3 MVC 拦截器
- spring原拦截器配置与新命名空间mvc:interceptors配置拦截器对比与注意事项
- mvc:interceptors 完全拦截问题
- springMVC之mvc:interceptors拦截器的用法
- SpringMVC源码总结(十一)mvc:interceptors拦截器介绍
- springMVC之mvc:interceptors拦截器的用法
- springMVC之mvc:interceptors拦截器的用法
- SpringMVC源码总结(十一)mvc:interceptors拦截器介绍
- 【数据库】存储过程
- ant 环境搭建
- iOS开发——隐藏状态栏
- 单项选择(RadioGroup)介绍与应用
- MyEclipse 启动报错:'Building workspace' has encountered a problem解决方法
- Spring3中的mvc:interceptors标签配置拦截器
- C#TreeView连接SQL数据库(可实现无限节点)
- 在 android monitor View Hierarchy 的 View 树上显示你的类名
- 关于NSInvocation-Tagert事件的多个参数实现方法
- 面试题 C/C++经典问题,及面试笔试题
- 采用AOP+log4j记录项目日志
- 我的世界一直有你
- IOS -BLOCK
- jsonp 跨域访问的一些常见问题