Spring validation can't find message -
i have problem validation in springmvc, can't find error messages...
have error says: no message found under code 'empty' locale 'en_gb'.
if configured in messages.properties.
i have configured in spring context servlet:
<beans:bean id="messagesource" class="org.springframework.context.support.reloadableresourcebundlemessagesource"> <beans:property name="basename"> <beans:value>web-inf/classes/messages</beans:value> </beans:property> </beans:bean>
in project file under src/main/resources/messages.properties, , is:
empty.user.password=il campo password non può essere lasciato vuoto empty.user.username=il campo username non può essere lasciato vuoto unique.user.username=l''username {0} è già usato empty=il campo non può essere vuoto
then have validator:
@override public void validate(object target, errors errors) { final user user = (user) target; validationutils.rejectifemptyorwhitespace(errors, "username", "empty"); validationutils.rejectifemptyorwhitespace(errors, "password", "empty"); if (userrepository.findbyusername(user.getusername()) != null){ errors.rejectvalue("username", "unique", new object[]{user.getusername()}, "the username exists"); } }
and in jsp:
<form:errors path="*" cssclass="alert error" element="div" />
i can't figure out can problem...
update: noticed deploying application in tomcat inside eclipse works...it has problem when execute using maven both jetty:run
, tomcat:run
have checked if messages.prop file getting copied on under classes directory
hth
Comments
Post a Comment