SpringMVC教程下篇
内容包括:
绑定数组:
将表单数据绑定到list:
@RequestMapping注解的三种用法:
Controller方法返回值:
乱码问题总结
异常处理:
照片上传:
RESTFUL支持:
拦截器使用
/*** 自定义拦截器* @author Steven**/
public class MyInterceptor1 implements HandlerInterceptor {//在Controller方法执行后被执行//处理异常、记录日志@Overridepublic void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)throws Exception {System.out.println("MyInterceptor1.afterCompletion.....");}//在Controller方法执行后,返回ModelAndView之前被执行//设置或者清理页面共用参数等等@Overridepublic void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)throws Exception {System.out.println("MyInterceptor1.postHandle.....");}//在Controller方法执行前被执行//登录拦截、权限认证等等@Overridepublic boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {System.out.println("MyInterceptor1.preHandle.....");//返回true放行,false拦截return true;}}