• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

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

 
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
Netbeans IDE Chrome 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
Netbeans IDE Chrome 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

 
I need a new interior decorator. This tiny ad just painted every room in my house purple.
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!