在struts2的<s:form>里面配置一个theme="simple"。就可以解决struts2标签自动换行的问题。
例子:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>LXIT通讯录</title>
<style type="text/css">
<!--
a{ color:#008EE3}
a:link { text-decoration: none;color:#008EE3}
A:visited {text-decoration: none;color:#666666}
A:active {text-decoration: underline}
A:hover {text-decoration: underline;color: #0066CC}
A.b:link {
text-decoration: none;
font-size:12px;
font-family: "Helvetica,微软雅黑,宋体";
color: #FFFFFF;
}
A.b:visited {
text-decoration: none;
font-size:12px;
font-family: "Helvetica,微软雅黑,宋体";
color: #FFFFFF;
}
A.b:active {
text-decoration: underline;
color: #FF0000;
}
A.b:hover {text-decoration: underline; color: #ffffff}
.table1 {
border: 1px solid #CCCCCC;
}
.font {
font-size: 12px;
text-decoration: none;
color: #999999;
line-height: 20px;
}
.input {
font-size: 12px;
color: #999999;
text-decoration: none;
border: 0px none #999999;
}
td {
font-size: 12px;
color: #007AB5;
}
form {
margin: 1px;
padding: 1px;
}
input {
border: 0px;
height: 26px;
color: #007AB5;
.unnamed1 {
border: thin none #FFFFFF;
}
.unnamed1 {
border: thin none #FFFFFF;
}
select {
border: 1px solid #cccccc;
height: 18px;
color: #666666;
.unnamed1 {
border: thin none #FFFFFF;
}
body {
background-repeat: no-repeat;
background-color: #9CDCF9;
background-position: 0px 0px;
}
.tablelinenotop {
border-top: 0px solid #CCCCCC;
border-right: 1px solid #CCCCCC;
border-bottom: 0px solid #CCCCCC;
border-left: 1px solid #CCCCCC;
}
.tablelinenotopdown {
border-top: 1px solid #eeeeee;
border-right: 1px solid #eeeeee;
border-bottom: 1px solid #eeeeee;
border-left: 1px solid #eeeeee;
}
.style6 {FONT-SIZE: 9pt; color: #7b8ac3; }
-->
</style>
<script type="text/javascript">
function check() {
var name = document.all['UserName'].value;
var password = document.all['Password'].value;
if (name == '' || password == '') {
alert('用户名或密码不能为空');
return false;
}
if (!name.match(/^\w{6,12}$/)) {
alert('用户名输入有误');
return false;
}
if (!password.match(/^\w{6,12}$/)) {
alert('密码输入有误');
return false;
}
document.loginform.action = "success.jsp";
}
</script>
</head>
<body>
<table width="681" border="0" align="center" cellpadding="0" cellspacing="0" style="margin-top:120px">
<tr>
<td width="353" height="259" align="center" valign="bottom" background="loginImage/5.gif"><table width="90%" border="0" cellspacing="3" cellpadding="0">
<tr>
<td align="right" valign="bottom" style="color:#05B8E4">Power by <a href="http://192.168.1.246:88/" target="_blank">lxit</a> Copyright 2010</td>
</tr>
</table></td>
<td width="195" background="loginImage/login_2_1.gif"><table width="190" height="106" border="0" align="center" cellpadding="2" cellspacing="0">
<s:form action="isExistUser" theme="simple">
<tr>
<td height="50" colspan="2" align="left"> </td>
</tr>
<tr>
<td width="60" height="30" align="left">登陆用户</td>
<td><!-- <input name="UserName" type="TEXT" style="background:url(loginImage/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" id="UserName"size="14">-->
<s:textfield theme="simple" id="username" cssStyle="background:url(loginImage/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF;ime-mode:disabled" size="14"></s:textfield>
</td>
</tr>
<tr>
<td height="30" align="left">登陆密码</td>
<td><!-- <input name="Password" TYPE="PASSWORD" style="background:url(loginImage/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF" id="Password" size="16"> -->
<s:password theme="simple" id="password" name="password" cssStyle="background:url(loginImage/login_6.gif) repeat-x; border:solid 1px #27B3FE; height:20px; background-color:#FFFFFF;ime-mode:disabled" size="16"></s:password>
</td>
</tr>
<tr>
<td height="40" colspan="2" align="center"><img src="loginImage/tip.gif" width="16" height="16"> 请勿非法登陆!</td>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" style="background:url(loginImage/login_5.gif) no-repeat" value=" 登 陆 " οnclick="check();" />
<input type="reset" name="Submit" style="background:url(loginImage/login_5.gif) no-repeat" value=" 注 册 "></td>
<tr>
<td height="5" colspan="2"></td>
</s:form>
</table></td>
<td width="133" background="loginImage/login_3.gif"> </td>
</tr>
<tr>
<td height="161" colspan="3" background="loginImage/login_4.gif"></td>
</tr>
</table>
</body>
</html>