【问题标题】:SPRING: Single quote not working in .properties file春天:单引号在 .properties 文件中不起作用
【发布时间】:2014-06-16 10:58:01
【问题描述】:

在我的api.properties 文件中,我有这个:

command.void='voiditem'
...

我在值的两端添加单引号以确保空格被转义,但它被呈现为原样(单引号仍然存在)。

@Value("${command.void}")
String command;
...
System.out.println(commad); //displays: 'voiditem'

出了什么问题?

【问题讨论】:

  • 没有出错。你期待什么?
  • 它显示为 command.void 键的值
  • @orvyl 不需要将字符串放在引号中
  • 我使用单引号来转义空格 (stackoverflow.com/questions/6537716/…)。我希望有voiditem 而不是'voiditem'(带引号)。无论如何,我真的应该删除单引号

标签: java spring maven


【解决方案1】:

属性文件中不需要保留单引号。

你得到带有修剪空格的值。

【讨论】:

    【解决方案2】:

    您不需要引号。这里有一些使用属性的例子:

    http://en.wikipedia.org/wiki/.properties

    【讨论】:

      猜你喜欢
      • 2017-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-04
      • 2018-06-14
      • 2013-01-21
      • 1970-01-01
      相关资源
      最近更新 更多