---
title: "关于struts2标签不换行的问题"
author: "liyanhui"
date: "2010-05-18T17:41:36Z"
tags: []
categories: ["Web前端"]
slug: "struts2"
draft: false
lastmod: "2010-05-18T17:41:36Z"
id: 669191
url: "https://liyanhui.iteye.com/blog/669191"
---

最近做了一个利用struts2 上传文件的例子，可是发现 浏览文件按钮和提交按钮不在一行，发现这不是我的css 样式的问题，而是由于struts2本标签的模板问题  
代码如下：

 

```
 <s:form action="../secretprotocol/fileUpload.do" method="post" name="form2" enctype="multipart/form-data">   
	<table width="100%" cellpadding="0" cellspacing="0" class="colortable">
	   <tr><td colspan="4">上传供员工下载的协议</td></tr>
	   <tr>
	   <td width="20"></td>
	   <td width="70">协议文件</td>
	       <td> <s:file  name="templetFile" id="templetFile" label="协议文件" theme="simple"/> </td>
	    	<td><s:submit value="提交" onclick="return submitBefore()" theme="simple"/>
	    	</td>
			<s:hidden name="templetTitle" id="templetTitle" value=""/>
	    	<s:hidden name="templetYear" id="templetYear" value=""/>
	    </tr>
	</table> 
   </s:form>
```

 解决方法：

     就是在struts2标签里加以个属性：theme="simple"就可以了。如下

```
 <s:form action="../secretprotocol/fileUpload.do" method="post" name="form2" enctype="multipart/form-data">   
	<table width="100%" cellpadding="0" cellspacing="0" class="colortable">
	   <tr><td colspan="4">上传供员工下载的协议</td></tr>
	   <tr>
	   <td width="20"></td>
	   <td width="70">协议文件</td>
	       <td> <s:file  name="templetFile" id="templetFile" label="协议文件" theme="simple"/> </td>
	    	<td><s:submit value="提交" onclick="return submitBefore()" theme="simple"/>
	    	</td>
			<s:hidden name="templetTitle" id="templetTitle" value=""/>
	    	<s:hidden name="templetYear" id="templetYear" value=""/>
	    </tr>
	</table> 
   </s:form>
```

 但是这样的话：struts2自带的标签（label）就显示不出来了 需要自己手动写，&lt;s:label value="名 称"/&gt;