![](/img/trans.png)
[英]Firefox does not render width and height properties of the A tag as expected
[英]Grails render tag and message.properties
我正在使用g:render grails标记来避免在应用程序中重复HTML的常见部分。 现在,我需要在其中一些属性中通过message.properties文件传递某些属性(例如,各节的标题),以便可以进行翻译。 为了使其正常工作,我使用以下结构:
<g:set var="title" value="${g.message (code: 'completed.thanks')}" />
<g:render template="thankYou" contextPath="/completed/" model="[title:title,other:other]" />
但是我想知道是否有更好的解决方案在render标签本身的模型中提供字符串。
如果传递的属性很多,则此方法可能不是最佳方法。 在那种情况下,我建议使用customTaglib来实现g:message的custo实现。 该自定义gMessage可以(例如)通过Convention查找以模型参数为前缀的属性。 比起gsp的渲染,您只能在模型中设置前缀字符串。
<g:render template="thankYou" contextPath="/completed/" model="[prefix: 'pagex']" />
在您的模板gsp中:
...
<custom:message code="completed.thanks" prefix="${prefix}"/>
<custom:message code="completed.byebye" prefix="${prefix}"/>
...
在属性文件中
pagex.thanks=bla bla bla
pagex.byebye=bla bla bla
pagey.thanks=bla bla bla
pagey.byebye=bla bla bla
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.