• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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

 
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • 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
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
getting messages from properties file works fine in JSP, but not in controller
 
Vyas Sanzgiri
Ranch Hand
Posts: 686
Chrome Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
I got it working by changing servlet-contxt.xml file

From



To

 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!