This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Software Teaming: A Mob Programming, Whole-Team Approach and have Woody Zuill and Kevin Meadows on-line!
See this thread for details.
  • 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

Issue with getting Message from properties file in Controller, but works in JSP

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting below error in my Controller class when trying to get message from resource file, but i am able to get the same message in jsp file

my properties file is messages.properties and not messages_en_US.properties , this might be issue, but i want to make it work using messages.properties because i cannot change the file name to messages_en_US as it might broke my other part of web application

this is my set up,
in servlet-contxt.xml file

in my controller this is what i do use AutoWired to load the bean



This is how i do in JSP file and it works fine


my properties file is as below



This is the error message
 
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you try spring:message

http://static.springsource.org/spring/docs/2.5.x/reference/spring.tld.html#spring.tld.message
 
ashish kulkarni
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
getting messages from properties file works fine in JSP, but not in controller
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Netbeans IDE Chrome Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry!!

Can you try:-

msgSrc.getMessage("label.firstname", null, null);
 
ashish kulkarni
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
msgSrc.getMessage("label.firstname", null, null);

This also does not work

I get below error


org.springframework.context.NoSuchMessageException: No message found under code 'label.firstname' for locale 'null'.
org.springframework.context.support.AbstractMessageSource.getMessage(AbstractMessageSource.java:135)
com.tauck.spring.HomeController.home(HomeController.java:40)

 
ashish kulkarni
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got it working by changing servlet-contxt.xml file

From



To

 
reply
    Bookmark Topic Watch Topic
  • New Topic