第一:我使用Spring 3.0我如何注入屬性值轉換成註釋配置Spring MVC的3.0控制器
配置我的控制器類時,我有一個問題。控制器使用Web服務,我想使用.properties文件定義端點地址。
@Controller
public class SupportController {
@Value("#{url.webservice}")
private String wsEndpoint;
...
在我的應用程序上下文XML的文件中,我定義的:
<context:property-placeholder location="/WEB-INF/*.properties" />
我一直在閱讀文檔,嘗試不同的方法(如添加前綴systemProperties),但我不斷收到一條錯誤消息,告訴我它不存在。
字段或屬性 'URL' 不能 上型 'org.springframework.beans.factory.config.BeanExpressionContext'
確定的對象中找到。我已經知道了。現在
,控制器:
@Value("#{settings['url.webservice']")
然後在上下文配置我有這樣的 「幫手豆」:
<util:properties id="settings"
location="/WEB-INF/supportweb.properties"></util:properties>
Duplicate:http://stackoverflow.com/questions/1741968/using-spring3-value-to-access-propertyplaceholderconfigurer-values – skaffman 2010-01-13 11:08:11