Hibernate Custom Validator Messages Spring MVC
up vote
0
down vote
favorite
I am trying to customize messages for Hibernate validation annotations (NOTNULL , NOTEMPTY ,...) so that the application is able to read them from .proparties file.
I tried the solutions from the answer here: use custom validation in hibernate
hibernate validator
but nothing works for me i still get the deafult messages (may not be null , may not be empty , ....).
Code sample :
application context.xml :
<bean name="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource">
<ref bean="resourceBundleLocator" />
</property>
</bean>
<bean name="resourceBundleLocator"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
user.java :
@NotNull
private String name;
messages.proparties :
user.name.notNull = incorrect name
java spring hibernate
add a comment |
up vote
0
down vote
favorite
I am trying to customize messages for Hibernate validation annotations (NOTNULL , NOTEMPTY ,...) so that the application is able to read them from .proparties file.
I tried the solutions from the answer here: use custom validation in hibernate
hibernate validator
but nothing works for me i still get the deafult messages (may not be null , may not be empty , ....).
Code sample :
application context.xml :
<bean name="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource">
<ref bean="resourceBundleLocator" />
</property>
</bean>
<bean name="resourceBundleLocator"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
user.java :
@NotNull
private String name;
messages.proparties :
user.name.notNull = incorrect name
java spring hibernate
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to customize messages for Hibernate validation annotations (NOTNULL , NOTEMPTY ,...) so that the application is able to read them from .proparties file.
I tried the solutions from the answer here: use custom validation in hibernate
hibernate validator
but nothing works for me i still get the deafult messages (may not be null , may not be empty , ....).
Code sample :
application context.xml :
<bean name="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource">
<ref bean="resourceBundleLocator" />
</property>
</bean>
<bean name="resourceBundleLocator"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
user.java :
@NotNull
private String name;
messages.proparties :
user.name.notNull = incorrect name
java spring hibernate
I am trying to customize messages for Hibernate validation annotations (NOTNULL , NOTEMPTY ,...) so that the application is able to read them from .proparties file.
I tried the solutions from the answer here: use custom validation in hibernate
hibernate validator
but nothing works for me i still get the deafult messages (may not be null , may not be empty , ....).
Code sample :
application context.xml :
<bean name="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource">
<ref bean="resourceBundleLocator" />
</property>
</bean>
<bean name="resourceBundleLocator"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
user.java :
@NotNull
private String name;
messages.proparties :
user.name.notNull = incorrect name
java spring hibernate
java spring hibernate
asked 23 hours ago
Mahmood Mousa
53
53
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
You need to mention the key name on your @NotNull annotation.
@NotNull(meassage="{user.name.notNull}")
private String name;
You can learn more from the link
https://teamtreehouse.com/library/displaying-validation-messages
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
You need to mention the key name on your @NotNull annotation.
@NotNull(meassage="{user.name.notNull}")
private String name;
You can learn more from the link
https://teamtreehouse.com/library/displaying-validation-messages
add a comment |
up vote
1
down vote
You need to mention the key name on your @NotNull annotation.
@NotNull(meassage="{user.name.notNull}")
private String name;
You can learn more from the link
https://teamtreehouse.com/library/displaying-validation-messages
add a comment |
up vote
1
down vote
up vote
1
down vote
You need to mention the key name on your @NotNull annotation.
@NotNull(meassage="{user.name.notNull}")
private String name;
You can learn more from the link
https://teamtreehouse.com/library/displaying-validation-messages
You need to mention the key name on your @NotNull annotation.
@NotNull(meassage="{user.name.notNull}")
private String name;
You can learn more from the link
https://teamtreehouse.com/library/displaying-validation-messages
answered 23 hours ago
Pooja Aggarwal
6757
6757
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372170%2fhibernate-custom-validator-messages-spring-mvc%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown