master
Keith Donald 15 years ago
parent c0d2c6fed4
commit 0d7f4117ab
  1. 10
      spring-framework-reference/src/validation.xml

@ -1384,13 +1384,13 @@ BindingResults results = binder.getBindingResults();}]]>
<section id="validation.mvc"> <section id="validation.mvc">
<title>Spring MVC 3 Validation</title> <title>Spring MVC 3 Validation</title>
<para> <para>
Spring MVC 3 now has the ability to automatically validate @Controller method arguments after binding. Beginning with Spring 3, Spring MVC has the ability to automatically validate @Controller inputs.
Before version 3, it was up to the developer to manually invoke object Validation logic. In previous versions it was up to the developer to manually invoke validation logic.
</para> </para>
<section id="validation.mvc.triggering"> <section id="validation.mvc.triggering">
<title>Triggering @Controller Method Argument Validation</title> <title>Triggering @Controller Method Argument Validation</title>
<para> <para>
To trigger validation of a @Controller method argument, simply annotate the argument as @Valid: To trigger validation of a @Controller input, simply annotate the input argument as @Valid:
</para> </para>
<programlisting language="java"><![CDATA[ <programlisting language="java"><![CDATA[
@Controller @Controller
@ -1473,8 +1473,8 @@ public class MyController {
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />]]> <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean" />]]>
</programlisting> </programlisting>
<para> <para>
With this configuration, anytime a @Valid @Controller method argument is encountered, it will be validated by the JSR-303 provider. With this configuration, anytime a @Valid @Controller input is encountered, it will be validated by the JSR-303 provider.
JSR-303, in turn, will enforce any constraints declared against the argument. JSR-303, in turn, will enforce any constraints declared against the input.
Any ConstaintViolations will automatically be exposed as BindingResults renderable by standard Spring MVC form tags. Any ConstaintViolations will automatically be exposed as BindingResults renderable by standard Spring MVC form tags.
</para> </para>
</section> </section>

Loading…
Cancel
Save