在controller设计时,可以让所有controller都继承基本controller,
在基本controller中,做异常处理的方法头部加上@ExceptionHandler({ Exception.class })注解,拦截所有异常,在此方法中对异常统一处理
包括异常类型的分类,异常返回页面等等
@RequestMapping
源码中value是这样定义的
/**
* The primary mapping expressed by this annotation.
* <p>In a Servlet environment: the path mapping URIs (e.g. "/myPath.do").
* Ant-style path patterns are also supported (e.g. "/myPath/*.do").
* At the method level, relative paths (e.g. "edit.do") are supported
* within the primary mapping expressed at the type level.
* Path mapping URIs may contain placeholders (e.g. "/${connect}")
* <p>In a Portlet environment: the mapped portlet modes
* (i.e. "EDIT", "VIEW", "HELP" or any custom modes).
* <p><b>Supported at the type level as well as at the method level!</b>
* When used at the type level, all method-level mappings inherit
* this primary mapping, narrowing it for a specific handler method.
*/
String[] value() default {};
表名在注解时,可以以value数组的形式传值
即:@RequestMapping(value = {"save.action","delete.action","update.action","query.action"})