Struts 常见问题


struts自动生成的布局样式与我们自己写的样式冲突

原文

应用struts2的时候,发现了一个很不好的事情,就是在应用标签的时候,自动生成的table、tr、td等布局样式。本来设计好的页面,被弄的乱七八糟。痛苦的要命啊。很想找个方法,既可以使用它的标签,又可以不用它的样式。

解决办法:

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标签中。

Joyce /
Published under (CC) BY-NC-SA in categories struts  tagged with struts