第一:我使用的是Spring 3.0
配置我的控制器类时遇到问题.控制器使用Web服务,我想使用.properties文件定义端点地址.
@Controller
public class SupportController {
@Value("#{url.webservice}")
private String wsEndpoint;
...
Run Code Online (Sandbox Code Playgroud)
在我的应用程序上下文xml文件中,我已经定义了这个:
<context:property-placeholder location="/WEB-INF/*.properties" />
Run Code Online (Sandbox Code Playgroud)
我一直在阅读文档,尝试不同的方法(如添加前缀systemProperties.),但我不断收到一条错误消息,告诉我它不存在.
在'org.springframework.beans.factory.config.BeanExpressionContext'类型的对象上找不到字段或属性'url'
好.我已经明白了.
现在,在控制器中:
@Value("#{settings['url.webservice']")
Run Code Online (Sandbox Code Playgroud)
然后在上下文配置中我有这个"帮助bean":
<util:properties id="settings"
location="/WEB-INF/supportweb.properties"></util:properties>
Run Code Online (Sandbox Code Playgroud)
Gee*_*nte 12
这也应该有效:
@Value("${url.webservice}")
private String wsEndpoint;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
18780 次 |
最近记录: |