---
title: "Struts2中清除默认产生的标签和布局样式"
author: "RobertLiu0905"
date: "2014-10-23T16:08:29Z"
tags: []
categories: ["Web前端"]
slug: "struts2"
draft: false
lastmod: "2014-10-23T16:08:29Z"
id: 2147199
url: "https://robertliu0905.iteye.com/blog/2147199"
---

在使用struts2的标签的时候，有没有因为默认产生的布局样式而抓破头呢？下面有两种方法解决这个问题，网上很多大牛说这个是struts2的优先，可能小虾涉世未深，还未能体会到，这里讲讲这两种方法吧。

  第一种：
  查看struts.properties或$ {struts-core2.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标签中

个人常用第二种。 :)