我希望能够在我的消息包键中包含空格,因为如果您不必也将空格转换为下划线,则将现有文本转换为键会更容易。
不过,spring 消息源似乎不喜欢这个。是否可以?
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)
最佳答案
如果您通过 .properties 资源包存储消息,请确保在键中的空格之前添加反斜杠。
Invalid\ username\ or\ password=Invalid username or password
请参阅维基百科中的属性文件示例:
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".
关于spring - 消息包键中的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5491517/