wood burning stoves 2.0*
The moose likes Spring and the fly likes Issue with getting Message from properties file in Controller, but works in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Issue with getting Message from properties file in Controller, but works in JSP" Watch "Issue with getting Message from properties file in Controller, but works in JSP" New topic
Author

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

ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 130
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


A$HI$H
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

Can you try spring:message

http://static.springsource.org/spring/docs/2.5.x/reference/spring.tld.html#spring.tld.message


===Vyas Sanzgiri===
My Blog
ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 130
getting messages from properties file works fine in JSP, but not in controller
Vyas Sanzgiri
Ranch Hand

Joined: Jun 16, 2007
Posts: 686

sorry!!

Can you try:-

msgSrc.getMessage("label.firstname", null, null);
ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 130
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

Joined: Aug 15, 2002
Posts: 130
I got it working by changing servlet-contxt.xml file

From



To

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Issue with getting Message from properties file in Controller, but works in JSP
 
Similar Threads
localisation problems
MVC 2.5 - How to get the MessageCodesResolver from within a Controller?
Spring MVC i18n problem
Issue with adding spring 3.0 to existing jsf 1.1 project
REST web service return both XML or JSON