如果未指定属性,是否可以将空字符串或空字符串作为将在spring文件中使用的默认值?目前我拥有的最好的是
<constructor-arg index="1" value="@{data.url:""}"/>
Run Code Online (Sandbox Code Playgroud)
""在代码中解析
Mar*_*tör 11
你尝试过使用SpEL吗?这样的事情可能是:
<constructor-arg index="1" value="#{'${data.url}'==null?'':'${data.url}'}"/>
Run Code Online (Sandbox Code Playgroud)
更新
我只记得有一种更简单的方法(正如这里所描述的那样).尝试:
<constructor-arg index="1" value="${data.url:''}"/>
Run Code Online (Sandbox Code Playgroud)
Bre*_*ntR 10
This will do the trick if you are using annotations in your source:
@Value("${data.url:#{null}}")
private String dataUrl;
Run Code Online (Sandbox Code Playgroud)
Empty-Elvis为我工作......
@Value("${http.proxyHost?:}")
public String proxyHost = null;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18367 次 |
| 最近记录: |