第一:我使用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