When you use a <struts:text name="..."/> Struts 2 Text jsp tag, you get a text from a .properties file in the page.
For example, if the .properties-file contains
foo.bar = This is the text.
The jsp tag <struts:text name="foo.bar"/> will output
This is the text.
Now i would like for all instances of <struts:text name="..."> in the webapp to also output the name attribute inside an HTML comment, like so:
<!-- foo.bar -->This is the text.
I tried creating my own jsp tag file (to use instead of <struts:text>) that contained
<%@attribute name="name" required="true"%>
<!-- ${name} --><struts:text name="${name}"/>
but it doesn’t work because <rtexprvalue> is set to false for the name attribute of the struts:text tag.
Any ideas how this can be accomplished?
(B) : Override default theme (is acceptable)
label.ftl
Add following code
<!-- ${parameters.name?html} -->.jsp
HTML output :
HTML source :
OR (not recommend)
label.ftl with only 4 lines of code
HTML source :
(A).jsp
HTML output :
HTML source :