Grails: Reading the Resource Bundle
我试图从资源包中获取消息/翻译列表,但它失败了(抛出异常)。该应用程序正在 IDEA 的 Tomcat 上运行:
1
2 |
Locale locale = new Locale(“en”);
ResourceBundle bundle = ResourceBundle.getBundle(‘i18n/dictionary’, locale); |
这里有什么问题。 i18n/dictionary 在类路径上。可能是 \\’i18n/dictionary\\’ 错误。
我可以得到消息源,但是我不能从这个(SPRING)对象中得到密钥:
1
|
def messageSource = grailsAttributes.getApplicationContext().getBean(“messageSource”);
|
资源路径不完整。如果您需要前端的转换表,也许以下控制器可能有用:
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
class ClientMessagesController {
def index = { def sep = ”; |
}
- 不要自己构建 JSON,使用 JsonBuilder
来源:https://www.codenong.com/9072565/