[@Controller]5 详解@InitBinder

@InitBinder

org.springframework.web.bind.annotation.InitBinder

public @interface InitBinder

Annotation that identifies methods which initialize the WebDataBinder which will be used for populating command and form object arguments of annotated handler methods.

由这个注释标识的方法,它初始化WebDataBinder,这个WebDataBinder用于填充被@InitBinder注释的处理方法的commandform对象。

Such init-binder methods support all arguments that RequestMapping supports, except for command/form objects and corresponding validation result objects. Init-binder methods must not have a return value; they are usually declared as void.

这个@InitBinder方法支持RequestMapping支持的所有参数,command/form对象和相关校验结果。@InitBinder方法不能有返回值,它必须声明为void

Typical arguments are WebDataBinder in combination with WebRequest or Locale, allowing to register context-specific editors.

通常参数是WebDataBinder(由WebRequestLocale结合而成)。

方法

String[] value

The names of command/form attributes and/or request parameters that this init-binder method is supposed to apply to.

@InitBinder方法需要的Command/form的属性名称或请求的参数名称。

Default is to apply to all command/form attributes and all request parameters processed by the annotated handler class. Specifying model attribute names or request parameter names here restricts the init-binder method to those specific attributes/parameters, with different init-binder methods typically applying to different groups of attributes or parameters.

默认是所有的Command/form的属性名称或请求的参数名称。指定特定的名称是为了区别不同的参数。

posted @ 2012-09-03 12:18  daveztong  阅读(1739)  评论(0编辑  收藏  举报