how to configure properties for mvc spring bean controller?
-
Is there a special way for doing this? What i got is: config.properties with param.key=value web.xml with ContextLoaderListener that reads the configuration pages-servlet.xml that defines servlet beans. What I want is to configure one of the beans in pages-servlet.xml with param.key. I'm using <property name="myField" value="${param.key}"/> in the xml but I see that the field is configured with ${param.key} instead of 'value'. What is the right way to configure the bean? Ok, I solved it by importing application context file that defines configuration bean into pages-servlet.xml. It works, but seems very wrong.
-
Answer:
Property placeholder is what you want. <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:property-placeholder location="classpath:/config.properties" /> <bean id="mybean" class="..."> <property name="xxx" value="${prop.value}" /> </bean> </beans>
Dima at Stack Overflow Visit the source
Related Q & A:
- How To Configure Your Freedom?Best solution by Yahoo! Answers
- How to configure android kernel?Best solution by Stack Overflow
- How to change properties of custom control?Best solution by Stack Overflow
- How to configure syslog for logging in Python?Best solution by Stack Overflow
- How to configure nginx for JBoss?Best solution by Server Fault
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.