Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何覆盖<;struts:text name="&引用/&燃气轮机;(Struts 2文本jsp标记)打印HTML注释中的name属性?_Java_Templates_Text_Struts2_Jsp Tags - Fatal编程技术网

Java 如何覆盖<;struts:text name="&引用/&燃气轮机;(Struts 2文本jsp标记)打印HTML注释中的name属性?

Java 如何覆盖<;struts:text name="&引用/&燃气轮机;(Struts 2文本jsp标记)打印HTML注释中的name属性?,java,templates,text,struts2,jsp-tags,Java,Templates,Text,Struts2,Jsp Tags,当您使用Struts 2文本jsp标记时,您会从页面中的.properties文件中获得一个文本 例如,如果.properties文件包含 foo.bar = This is the text. jsp标记将被输出 This is the text. 现在,我希望webapp中的所有实例也能在HTML注释中输出name属性,如下所示: <!-- foo.bar -->This is the text. 这是文本。 我尝试创建自己的jsp标记文件(用来代替),其中包含 <

当您使用Struts 2文本jsp标记时,您会从页面中的.properties文件中获得一个文本

例如,如果.properties文件包含

foo.bar = This is the text.
jsp标记
将被输出

This is the text.
现在,我希望webapp中的所有
实例也能在HTML注释中输出name属性,如下所示:

<!-- foo.bar -->This is the text.
这是文本。
我尝试创建自己的jsp标记文件(用来代替
),其中包含

<%@attribute name="name" required="true"%>

<!-- ${name} --><struts:text name="${name}"/>

但是它不起作用,因为
struts:text
标记的
name
属性将
设置为
false

有什么办法可以做到这一点吗

# PROPERTIES
copyright.year=2011
(B):覆盖默认主题

label.ftl

添加以下代码

HTML源代码:

2011
<!-- copyright.year -->
<label id="form_name_copyright_year">2011</label>
<!-- copyright.year -->2011
2011
<!-- copyright.year --> 2011

.jsp

<s:label key="copyright.year" />
<s:property value="text('copyright.year')" escapeHtml="false" />
HTML源代码:

2011
<!-- copyright.year -->
<label id="form_name_copyright_year">2011</label>
<!-- copyright.year -->2011
2011
<!-- copyright.year --> 2011
2011

foo.bar=这是文本。
?@Ischin:
foo.bar
只是一个例子。我希望它对.properties文件中的所有数百个文本都能起同样的作用。谢谢,这应该能起作用,尽管我不太喜欢在所有标记上复制
文本(“…”)
escapeHtml=“false”
。我真的希望有一个格式为
@Ischin的标记:
不是UI标记,因此它没有模板,也不可主题化。@Christoffer是的。请参阅我的最新答案。您可以覆盖其他不重要的标记,如
label
div
,…@Ischin:再次感谢!为什么不推荐第二个呢?看起来很接近我想要的。@Christoffer的一些其他属性(在
label.ftl
中)将失去效力,但如果
从不用于其他目的,这并不是什么大问题。