aspose file tools*
The moose likes Spring and the fly likes How to use spring:message tag as labels in java web application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to use spring:message tag as labels in java web application" Watch "How to use spring:message tag as labels in java web application" New topic
Author

How to use spring:message tag as labels in java web application

Yogesh Bali
Greenhorn

Joined: May 29, 2009
Posts: 21
Hi..

Please guide me from start on how to use the spring message tag.. if i want to use it in my application to make it internationalized.
That would be a great help to me.

Thanks and Regards,
Yogesh
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

First you need to declare your message bundle :

Here, the file called messages.properties (or any other international bundle, like messages_en_GB.properties) should be in the classpath. It should hold your messages. For example:

Then using the message tag :


[My Blog]
All roads lead to JavaRanch
Yogesh Bali
Greenhorn

Joined: May 29, 2009
Posts: 21
first of all, thanks Christophe for the help. But the job is still not done. What i did is as follows :

Step 1: i first created a xml file with the name applicationContext.xml in the resources folder

Step 2 : i created a file messages.properties in the same resources folder

Step 3 : i included the following jar files in the lib folder :
commons--logging-1.1.1.jar and spring.jar
Step 4 : i did the following changes in the web.xml file :

Step 5 : i made a jsp, included the following two tags in it

and

And on execution of this application on Eclipse IDE, i receive the following exception


Please help, i am unable to move ahead from this point in my application.
Yogesh Bali
Greenhorn

Joined: May 29, 2009
Posts: 21
Thank you so much Christophe Verré, my application is running fine.. all the labels are getting values from messages.properties file... The mistake what i was doing was that i was not including the messages.properties file to the classpath... and now when i added it to the build, its working fine. Thanks and its a great concept to make the application internationalized..
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1220
    
    1

hi yogesh

i am getting same error.
please tell me where you have placed message.properties in your build.

thanks
abhay
pradeep gamage
Ranch Hand

Joined: Aug 03, 2009
Posts: 85

put message.properties file in to your class path then this error will be solve


Software Engineer(BSC):SCJP 1.5
(Knowledge is power when applied)
Shahid Ansari
Greenhorn

Joined: Jun 12, 2010
Posts: 3
pradeep gamage wrote:put message.properties file in to your class path then this error will be solve


Hi, what do you mean by class path here ?
My message.properties is inside /WEB-INF and is as follows:


But when I leave the first name empty while submitting I get the following error:


reg is my commandName in the JSP form page.

Can someone please help me in this...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use spring:message tag as labels in java web application