六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 148|回复: 0

Struts表单布局;theme三个属性值:simple,xhtml,css_xhtml

[复制链接]

升级  50%

5

主题

5

主题

5

主题

童生

Rank: 1

积分
25
 楼主| 发表于 2013-2-7 23:22:33 | 显示全部楼层 |阅读模式
解决Struts2 Form表单自己布局之前先看看 theme 属性, theme属性提供 三个属性值:simple,xhtml,css_xhtml,分别对应3个模板主题。
 
simple就是什么模板都不要,xhtml是默认的,如果你的页面用了css布局,又想用struts2的增强功能就用css_xhtml。
 
先看看一个Struts2 表单应用
<s:form action="saveuser.action" theme="simple">    <s:textfield name="u_id" label="用户名"     cssClass="border"></s:textfield></s:form> 
 
当theme 属性值设置为simple,生成的HTML代码为
 
 
<input type="text" name="u_id" value="" id="saveuser_u_id" class="border"/> 
 这时如果使用验证框架,则验证Message不能正常显示,需要添加
<s:fielderror><s:param>u_id</s:param></s:fielderror> 
当theme 属性值设置为xhtml,生成的HTML代码为
<table class="wwFormTable"><tr errorFor="saveuser_u_id">    <td align="center" valign="top" colspan="2"><span class="errorMessage">请填写用户ID </span></td></tr><tr>    <td class="tdLabel"><label for="saveuser_u_id" class="errorLabel">用户名:</label></td>    <td><input type="text" name="u_id" value="" id="saveuser_u_id" class="border"/></td></tr><ul><li><span class="errorMessage">请填写用户ID </span></li></ul></table> 
 
看到这相信使用Struts2标签的都知道怎么自定义布局了。
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表