java - MessageSource getMessage method not working in Spring mvc -


i have developed spring mvc application want read property value properties file located inside of weblogic server.

have performed following steps:

created project specific folder appconfig in following path: oracle/middleware/oracle_home/user_projects/domains/wl_server/config/rmsconfig

placed properties file named commonconfig.properties inside of it.

have edited setdomainenv.cmd following entry,

if not "%ext_post_classpath%"=="" (    set ext_post_classpath=%ext_post_classpath%;%domain_home%\config\appconfig if not "%post_classpath%"=="" (     set post_classpath=%post_classpath%;%ext_post_classpath% ) else (     set post_classpath=%ext_post_classpath%  ) ) 

please find below spring bean configuration file this:

  <?xml version="1.0" encoding="utf-8"?>     <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xmlns:util="http://www.springframework.org/schema/util"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemalocation="http://www.springframework.org/schema/beans   http://www.springframework.org/schema/beans/spring-beans.xsd       http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-4.3.xsd       http://www.springframework.org/schema/util   http://www.springframework.org/schema/util/spring-util-4.3.xsd">   <bean id="commonprops" class="org.springframework.context.support.reloadableresourcebundlemessagesource">       <property name="basename" value="commonconfig" />       <property name="cacheseconds" value="120" />  </bean> </beans> 

in java spring bean class refering follows:

         @component           public class locationclient{             @autowired             private messagesource commonprops;             public void showmessage(){              system.out.println(commonprops.getmessage("common.line", null, null, null));            }        } 

now commonprops not null "common.line" printing null in console.

please find below property file entry:

common.line=382 

anyone has suitable solution this???

i think have add property file in classpath or in web-inf folder.

this note java spring docs.

for typical web application, message files placed in web-inf: e.g. "web-inf/messages" basename find "web-inf/messages.properties", "web-inf/messages_en.properties" etc arrangement "web-inf/messages.xml", "web-inf/messages_en.xml" etc. note message definitions in previous resource bundle override ones in later bundle, due sequential lookup.

refer link more information: reloadableresourcebundlemessagesource


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -