SPR-6709 Handle RequestBodyNotValidException and update reference docs

This commit is contained in:
Rossen Stoyanchev
2011-06-02 18:27:50 +00:00
parent bfecedf5e2
commit 9d2ee7061c
4 changed files with 44 additions and 4 deletions

View File

@@ -1369,9 +1369,18 @@ public void handle(@RequestBody String body, Writer writer) throws IOException {
<bean id="castorMarshaller" class="org.springframework.oxm.castor.CastorMarshaller"/>
</programlisting>
<para>An <classname>@RequestBody</classname> method parameter can be annotated with
<classname>@Valid</classname>, in which case it will validated using the configured
<classname>Validator</classname> instance. When using the MVC namespace a JSR-303
validator is configured automatically assuming a JSR-303 implementation is available
on the classpath. If validation fails a <classname>RequestBodyNotValidException</classname>
is raised. The exception is handled by the <classname>DefaultHandlerExceptionResolver</classname>
and results in a <literal>500</literal> error send back to the client along with
a message containing the validation errors.</para>
<note>
<para> Also see <xref linkend="mvc-annotation-driven"/> for information on
configuring message converters through the MVC namespace.</para>
configuring message converters and a validator through the MVC namespace.</para>
</note>
</section>