Balasaheb
Balasaheb

Reputation: 635

How to change value of code in <spring:message code>

I am in trouble by using in my html. Actually i have defined some errors in message.property file.

message.property:

spraying_schedule_master_unq1=Duplicate Record.
post_role_master_unq1=Record for This Applicable Date Already Exists.

If any error occurred in controller class I have set that error to session:

Controller:

session.setAttribute(SessionAttribute.error.toString(), error); 

And that error message i am showing at html:

html:

<spring:message code="${error}" />

It works fine when error occurred as defined in property file but problem began when sessoin error contain different error from property file that time it shows error. So my problem is when error message is not present in property file it should display default message. Can I do that, if yes how? please give me a solution i am stuck here. Thanks

Upvotes: 1

Views: 2998

Answers (1)

Dani
Dani

Reputation: 3764

<spring:message code="${error}" text="your default text here" />

Upvotes: 4

Related Questions