下面是我的一个Stuts2页面
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>List Books</title>
</head>
<body>
<img src="img/bg.jpg" width=100% />
<br>
<div>
<table border=1 cellspacing=1 style="word-break: keep-all" width=100% fixed=true >
<s:iterator value="list" var="books">
<tr>
<td width=100><s:property value="#books.categorieNo" /></td>
<td width=100><s:property value="#books.title" /></td>
<td width=100><s:property value="#books.author" /></td>
<td width=100><s:property value="#books.edition" /></td>
<td width=100><s:property value="#books.noOfCopies" /></td>
<td width=100><s:property value="#books.description" /></td>
<td width=100><s:property value="#books.price" /></td>
<td width=100><s:property value="#books.fileName" /></td>
<td width=100><s:property value="#books.publications" /></td>
<td width=100><img src="<s:property value="#books.image" />" /></td>
<td width=100><s:checkbox name="checkBox" /></td>
<td width=100><s:textfield id="quantity" required="true"></s:textfield></td>
</tr>
</s:iterator>
</table>
</div>
</body>
</html>
我想让他们都在同一行显示,可是最后两列的checkbox和textfield总是跟前面的不再一行,是什么原因啊?
求解答!!!

解决方案 »

  1.   

    这是因为struts标签本来就会自动换行。http://hi.baidu.com/everything_is_truth/blog/item/6321907269dfe1108701b082.html
      

  2.   

    我试了下,在struts.xml里面加
    <constant name="struts.ui.theme" value="simple"/>
    可以解决你的问题!
      

  3.   

    2楼的办法是可以的, 因为Struts2的默认Form标签是默认带简单表格的格式的。
      

  4.   

    是哪个标签带有自动换行,我可是把他们放在一个iterator里面
      

  5.   

    <img src="<s:property value="#books.image" />" />换成<img src='<s:property value="#books.image" />' />单引号试下,是不是页面宽度不够啊。
      

  6.   

    2楼正解,指定表单的主题是simple,然后你就可以像HTML文件一样设置样式了
      

  7.   

    对对对,struts标签 解析的时候 会加table标签,查看源代码或 html都可以看出来
      

  8.   

    你要用s标签就全用  
    默认情况下 他会对s标签的内容进行简单布局
    不过这个布局的效果不是太好
    我通常都是用 simple=false 自己来对页面布局
      

  9.   

    simple=false 是取消strut 自带的布局
      

  10.   

    不得不承认楼主的HTML写的太水了,一点都没有符合HTML的标准规范,您还是先学习下XHTML的标准规范吧,否则你会吃亏的!
      

  11.   

    谢谢,html从没系统学过,只是现在要做项目了,才用到一点学一点
      

  12.   

    也可以直接在 table 标签中加上  theme=simple 就可以不换行了
      

  13.   

     <td width=100><img src="<s:property value="#books.image" />" /></td>
    这个吗?没有设置图片的大小。图片把表格撑大了。
      

  14.   


    属性要小写,值要加双引号,不要用百分比!
    例如:
    <images src="URL" width="20" height="20"/>