Springmvc整理6-----springmvcブロック(2)
1582 ワード
public class HandlerInterceptor1 extends HandlerInterceptorAdapter {// HandlerInterceptorAdapter
/**
* preHandle , 、 ;
* postHandle , ModelAndView;
* afterCompletion , ex null , 。
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
System.out.println("===========HandlerInterceptor1 preHandle");
return true;
}
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
/**
* modelview, login
*/
modelAndView.setViewName("/login");
System.out.println("===========HandlerInterceptor1 postHandle");
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
System.out.println("===========HandlerInterceptor1 afterCompletion");
}
}
プロファイル: <!--
<mvc:interceptors>:
WebRequestInterceptors
mvc:mapping:
URL , 。 URL
:<mvc:mapping path="/interceptorTest/**" />
URL
-->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/interceptorTest/**" />
<bean class="com.boventech.learning.intercepter.HandlerInterceptor1" />
</mvc:interceptor>
</mvc:interceptors>