0

While reading properties file from folder com.resources I got following error

javax.servlet.jsp.JspTagException: No message found under code 'com.info.write.text' for locale 'en_US'.

I am not using maven. So, I understand that spring will not read the resources automatically.

I know how to write and read data from simple property file in java is simple task as, need to provide path using FileReader now the question is how I can provide path to properties file?

This is some relevant part of my dispatcherServlet-servlet.xml

<bean id="messageSource"
        class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="message" />
    </bean>

here is data of property file i.e (message.property)

com.info.write.text=Greetings of the day

This is how I am trying to use data from property file as message

<p><spring:message code="com.info.write.text" /></p> 

and the file structure to message.properties is

src/com/resources/message.properties

How to read properties file in spring without using maven or any build tool(directly) ?

  • Did you try renaming your `message.properties` file to `message_en.properties`? – jlumietu Sep 19 '16 at 11:52
  • 1
    Check this http://stackoverflow.com/questions/11150869/resourcebundle-not-found-for-messagesource-when-placed-inside-a-folder – abaghel Sep 19 '16 at 11:53
  • @jlumietu this won't work the problem is spring don't know the path of properties file – bananas Sep 19 '16 at 12:02

1 Answers1

0

Either use full name in dispatcherServlet-servlet.xml like

<property name="basename" value="src/com/resources/message" />

or use ClassPath like

<property name="basename" value="classpath*:resources/message" />
bananas
  • 1,176
  • 2
  • 19
  • 39