[英]Grails Set Error Message From messages.properties In External JavaScript File
如何從messages.properties文件在外部Java腳本文件上設置錯誤消息,以便錯誤消息將根據本地或語言(例如英語,德語等)自動更改。
如何在外部Java腳本文件上使用<g:message code="" default="" />
或${message(code:'',default:'')}
?
在我的應用程序中,我通過以下方式將模型對象傳遞給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(..)}"/>
您可以像上面顯示的那樣通過它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.