@ModelAttribute

增强型用来绑定java bean或属性到view model上的,在Controller内会在所有@RequestMapping方法之前调用

Annotation that binds a method parameter or method return value to a named model attribute, exposed to a web view. Supported for controller classes with @RequestMapping methods.

Can be used to expose command objects to a web view, using specific attribute names, through annotating corresponding parameters of an @RequestMapping method.

Can also be used to expose reference data to a web view through annotating accessor methods in a controller class with@RequestMapping methods. Such accessor methods are allowed to have any arguments that @RequestMapping methods support, returning the model attribute value to expose.

Note however that reference data and all other model content is not available to web views when request processing results in an Exception since the exception could be raised at any time making the content of the model unreliable. For this reason @ExceptionHandler methods do not provide access to a Model argument.

具体实例见Spring MVC and the @ModelAttribute Annotation

results matching ""

    No results matching ""