主题(theme)

//index.jsp
theme测试
<a href="theme.action">go</a>


//theme.jsp
在struts.xml中控制theme,默认为xhtml,可以设置为:simple/css_html/ajax
<br/>
要看页面源码
<ol>
<li>
<s:form> <!-- formFieldError 默认带一个小点 -->
<div class="formFieldError">
<s:fielderror /> <!-- 取出放入的对应校验错误 -->
</div>
<s:textfield name='aaa'></s:textfield>
</s:form>
</li>
</ol>


//theme1.jsp
<style type="text/css">
.formFieldError {
font-family: verdana, arial, helvetica, sans-serif;
font-size: 12px;
color: #FF3300;
vertical-align: bottom;
}

.formFieldError ul { /*list-style-type: none*/
margin: 0px;
padding: 3px;
vertical-align: middle;
}

.formFieldError ul li {
/* 默认带了 ul li,重写ul li覆盖了原来的,去掉了小点,
也可以重写或定义自己simple主题,覆盖原来的 */
list-style-type: none
}
</style>

用CSS控制显示
<br/>
要看页面源码
<ol>
<li>
<s:form><!-- 去掉了默认带的小点 -->
<div class="formFieldError">
<s:fielderror />
</div>
<s:textfield name='aaa'></s:textfield>
</s:form>
</li>
</ol>
//struts.xml
<constant name="struts.i18n.encoding" value="GBK" /> <!-- internationalization -->
<constant name="struts.ui.theme" value="css_xhtml" /><!--
<constant name="struts.ui.theme" value="mytheme" /> --><!-- 定义自己的主题 -->
<package name="theme" extends="struts-default" namespace="/">
<action name="theme" class="com.bjsxt.struts2.theme.ThemeAction">
<result>/theme.jsp</result>
</action>
</package>
//action
package com.bjsxt.struts2.theme;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class ThemeAction extends ActionSupport {

public String execute() { //添加校验错误信息
this.addFieldError("fielderror.test", "wrong!");
return SUCCESS;
}


}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值