消息包密钥中的空格

mko*_*yak 3 spring internationalization message-bundle

我希望能够在我的消息包密钥中包含空格,因为如果您不必将空格转换为下划线,则更容易将现有文本转换为键.

春天的消息来源似乎并不喜欢这样.可能吗?

2011-03-30 15:45:56,519 ERROR [org.springframework.web.servlet.tags.MessageTag] - No message found under code 'Invalid username or password' for locale 'en_US'.
javax.servlet.jsp.JspTagException: No message found under code 'Invalid username or password' for locale 'en_US'.
    at org.springframework.web.servlet.tags.MessageTag.doStartTagInternal(MessageTag.java:183)
Run Code Online (Sandbox Code Playgroud)

Adr*_*ith 13

如果要通过.properties资源包存储消息,请确保在键中的空格之前添加反斜杠.

Invalid\ username\ or\ password=Invalid username or password
Run Code Online (Sandbox Code Playgroud)

请参阅Wikipedia中的属性文件示例:

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

# Add spaces to the key
key\ with\ spaces = This is the value that could be looked up with the key "key with spaces".
Run Code Online (Sandbox Code Playgroud)