MyCode(一串grails中的一行)
<h3><g:message code="view.hello"/><span style="color:orange"><g:message code="view.world"/></span><h3></h3>
输出
HelloWorld(橙色世界)
但不喜欢我把这行代码放进去。我希望做这样的事情。
我想要的代码
messages.properties(放在字符串+ html中)
view.helloword = hello&gt; span style =“color:orange”&gt; World&gt; / span&gt;
但输出是:
你好&gt; span style =“color:orange”&gt;世界&gt; / span&gt;
别看html代码。我怎么解决?
答案 0 :(得分:1)
可以按以下方式完成:
//messages.properties
view.helloworld=Hello <span style="color:orange">World</span>
//gsp
<h3><g:message code="view.helloworld"/></h3>
答案 1 :(得分:1)
您可以将任何html添加到消息中,并在视图中呈现消息非常简单。以下答案适用于Grails 3.0.1
${raw(message(code:"view.hello"))}
您可以对任何类似html的字符串使用相同的方法。