SPring拦截器:
接口L"org.springframework.web.servlet.HandlerInterceptor"包含的方法:
1,public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception 普通 在某一个控制器的方法执行之前调用;
2,public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception 普通 正在执行的某一个E控制器的方法
3,public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception 普通 控制器的方法执行完毕后调用
applicationContext.xml文件中定义interceptors
<mvc:interceptors>
<mvc:interceptor>
<bean class="cn.mldn.util.validate.ValidationInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>
拦截器中最常使用的类:“org.springframework.web.method.HandlerMethod”
1,public Object getBean() 普通 返回触发次拦截器的程序类(XxxAction)
2,public Method getMethod() 普通 取得具体操作XxxAction中方法的Method对象
3,public Class<?> getBeanType() 普通 去得触发次拦截器程序类的class对象
4,public MethodParameter[] getMethodParameters 普通 取得所有提交到此方法上的参数
又有用户提交的参数,在拦截器里面都使用""org.springframework.core.MethodParameter""程序类进行接收;
1,public Method getMethod() 普通 取得调用的方法对象
2,public String getParameterName() 普通 取得提交到次Action上的参数名称
3,public Class<?> getParameterType() 普通 取得此参数的类型