如何在 messages.properties 文件中的外部java脚本文件上设置错误消息,以便根据英语,德语等本地或语言自动更改错误消息。
如何在外部java脚本文件上使用 <g:message code="" default="" />
或 ${message(code:'',default:'')}
?
答案 0 :(得分:0)
在我的应用程序中,我通过以下方式将模型对象传递给javascript:
<g:javascript>
// Scroll the page to the position of the add button clicked by the user
jQuery(document).ready(function() {
window.scrollBy(0, ${pageScroll});
});
</g:javascript>
在您的示例中,您可以使用标记
定义新变量<g:set var="tranlsatedLabel" value="${g.message(..)}"/>
你可以像我上面所说的那样传递它。