Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I found an answer to this in another question and it worked for me: <a href="https://stackoverflow.com/questions/6540300/spring-3-0-mvc-seems-to-be-ignoring-messages-properties">spring 3.0 MVC seems to be ignoring messages.properties</a></p> <p>The confusing part to me, as I am new to Spring, is that I expected to be able to put the message in ValidationMessages.properties. However, this error happens at binding time, before validation. So instead of using ValidationMessages.properties, use your regular ResourceBundle messages.properties file.</p> <p>Put this in your ??-servlet.xml file:</p> <pre><code>&lt;bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"&gt; &lt;property name="basename" value="messages"/&gt; &lt;/bean&gt; </code></pre> <p>Put lines like these in your messages.properties file.</p> <pre><code>typeMismatch.myRequest.amount=Amount should be a number. methodInvocation.myRequest.amount=Amount should be a number. </code></pre> <p>In this example myRequest is my form model and amount is a property in that form. typeMismatch and methodInvocation are pre-defined and correspond to binding/conversion exceptions like the one you seem to be getting. I had a hard time finding good documentation for them or a list of values, but I found that they correspond to ERROR_CODE constants in some Spring exceptions. <a href="http://static.springsource.org/spring/docs/2.5.x/api/constant-values.html#org.springframework.beans.MethodInvocationException.ERROR_CODE" rel="nofollow noreferrer">http://static.springsource.org/spring/docs/2.5.x/api/constant-values.html#org.springframework.beans.MethodInvocationException.ERROR_CODE</a></p> <p>I put my messages.properties file for this project in the root of my source folder, which puts it in the root of my classpath, along with ValidationMessages.properties.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload