去除 struts2 标签中的自动生成的布局样式table/tr/td

去除 struts2 标签中的自动生成的布局样式table/tr/td使用struts2的时候发现如果按照默认的方式使用ui标签,会自动加上标签,比如:会显示成:  有时候并不需要这些tdtr,所以可以这样写: 或者:修改struts2的配置文件struts2中包含了一些默认的模版文件(${struts-core-2.06.jar}/template),其中有ajax/simple/xhtml等.查看struts.

使用struts2的时候发现如果按照默认的方式使用ui标签,会自动加上<tr><td>标签,比如:

<s:textfield key=”username”/>

会显示成:

<tr class=“xxx”><td><input type=text name=username/></td></tr>  
<tr class=“xxx”><td><input type=text name=username/></td></tr>

有时候并不需要这些td tr,所以可以这样写:

<s:textfield key="username" theme="simple"/> 
<s:textfield key="username" theme="simple"/>

或者:修改struts2的配置文件

struts2中包含了一些默认的模版文件($ {struts-core-2.06.jar}/template),其中有ajax/simple/xhtml等.

查看struts.properties或$ {struts-core-2.06.jar}/org/apache/struts2/default.properties文件,其中有如下配置:

struts.ui.theme=xhtml 
struts.ui.templateDir=template 
struts.ui.templateSuffix=ftl 

这一段就是关于struts2模版的配置信息,我们可以修改struts.properties文件,将其改成

struts.ui.theme=simple

如果没有struts.properties文件,可以修改struts.xml文件,在其中加入如下行

<constant name="struts.ui.theme" value="simple" />

struts.ui.theme=simple可以解决struts2标签自动换行问题,即不再自动被添加进table标签中。

今天的文章去除 struts2 标签中的自动生成的布局样式table/tr/td分享到此就结束了,感谢您的阅读,如果确实帮到您,您可以动动手指转发给其他人。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/26210.html

(0)
编程小号编程小号

相关推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注