差点没被郁闷死,开始不知道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.ui.templateDir=template
struts.ui.templateSuffix=ftl
方法二:
如果没有struts.properties文件,可以修改struts.xml文件,在其中加入如下行
<constant name="struts.ui.theme" value="simple" />
<constant name="struts.ui.templateDir" value="template" />
<constant name="struts.ui.templateSuffix" value="ftl" />
struts.ui.theme=simple可以解决struts2标签自动换行问题,即不再自动被添加进table标签中
偶选择了方法二,简单点,另外要注意的是,这三行放在<struts>标签里,其它标签外。 加油!