【发布时间】:2010-01-13 09:39:51
【问题描述】:
首先:我使用的是 Spring 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']")
然后在上下文配置中我有这个“帮助 bean”:
<util:properties id="settings"
location="/WEB-INF/supportweb.properties"></util:properties>
【问题讨论】: