MyCode (a line in a gsp of grails)
<h3><g:message code="view.hello"/><span style="color:orange"><g:message code="view.world"/></span><h3></h3>
Output
HelloWorld(in orange World)
But dont like how i put this line of my code. I wish do something like this.
the code i want
messages.properties (put inside string+html)
view.helloword= hello>span style="color:orange">World>/span>
But output is:
hello>span style="color:orange">World>/span>
Dont look html code. how i can resolve?
Can be done as below:
//messages.properties
view.helloworld=Hello <span style="color:orange">World</span>
//gsp
<h3><g:message code="view.helloworld"/></h3>
You can add any html to messages and render message in view quite easy. Answer below works in grails 3.0.1
${raw(message(code:"view.hello"))}
You can use same approach for any html-like string.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.