expand spring-mvc to support more type of resover
-
config the ApplicationContext
<mvc:annotation-driven> <mvc:argument-resolvers> <bean class="org.jhat.spring.mvc.extend.method.annotation.RequestAttributeMethodArgumentResolver"/> <bean class="org.jhat.spring.mvc.extend.method.annotation.RequestJsonParamMethodArgumentResolver"/> </mvc:argument-resolvers> </mvc:annotation-driven> -
Use org.jhat.spring.mvc.extend.bind.annotation.RequestAttribute to resolve named parameter
URL: /jhat/user.do?user.name=Jhat&[email protected] Arg: @RequestAttribute("user") user -
Use org.jhat.spring.mvc.extend.bind.annotation.RequestJsonParam to resolve named json parameter
URL:/jhat/user.do?user={name: 'Jhat', email: '[email protected]'} Arg: @RequestJsonParam("user") user -
the Validation need handle MethodArgumentNotValidException in @Controller
@ResponseBody @ExceptionHandler(MethodArgumentNotValidException.class) public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) { BindingResult result = e.getBindingResult(); return result.getFieldError().getDefaultMessage(); } -
if need java.util.Map should use org.jhat.spring.mvc.extend.util.MapWapper to replace