• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 :

 
Yogesh Bali
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Ranch Hand
Posts: 1376
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi yogesh

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

thanks
abhay
 
Ranch Hand
Posts: 85
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
put message.properties file in to your class path then this error will be solve
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic