SSH系列(二)struts标签库
来源:互联网 发布:淘宝亦美珊泳衣模特 编辑:程序博客网 时间:2024/06/02 04:01
Struts中最常用的有三个,分别为:bean,logic,html。
bean:用来在属性范围中定义或取得属性的,同时可以读取资源文件信息
logic:替代JSTL中的判断和循环
html:代替页面表单,完成自动回填以及错误信息的显示
bean标签的使用:
1、使用之前先引入标签库:
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
2、<bean:write>标签输出普通的字符串:
<h1>测试bean_write标签</h1><hr><li>普通字符串</li><br>hello(标签):<bean:write name="hello" /><br>
3、<bean:write>标签输出html文本:
在<bean:write>标签中有一个filter属性,默认情况filter为true,标示不识别html文本,当设置为false时,会按照html文本内容显示
<li>html文本</li><br>bj(default):<bean:write name="bj" /><br>bj(filter="true"):<bean:write name="bj" filter="true"/><br>bj(filter="false"):<bean:write name="bj" filter="false"/><br>
4、格式化日期和数字:
format属性不仅用于控制对日期格式的显示,还可以用来控制对数字显示格式的控制:
<li>格式化日期</li><br>today(default):<bean:write name="today"/><br>today(format="yyyy-MM-dd HH:mm:ss"):<bean:write name="today" format="yyyy-MM-dd HH:mm:ss"/><br><p><li>格式化数字</li><br>n(default):<bean:write name="n" /><br>n(format="###,###.#####):<bean:write name="n" format="###,###.#####"/><br>n(format="###,###.00000):<bean:write name="n" format="###,###.00000"/><br>
logic标签的使用:
1、引入所需要的标签库:
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
2、logic:empty,logic:notempty,logic:present,logic:notpresent:
<logic:empty name="attr1">attr1为空<br></logic:empty><logic:notEmpty name="attr1">attr1不为空<br></logic:notEmpty><logic:present name="attr1">attr1存在</logic:present><logic:notPresent name="attr1">attr1不存在</logic:notPresent>
判断是否为空和是否存在。
html标签的使用:
1、引入需要的标签库:
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
2、<html:messages>标签和<html:errors>标签的使用:
<font color="red"><html:messages id="msg" property="error_1"><bean:write name="msg"/></html:messages></font><font color="blue"><html:messages id="msg" property="error_2"><bean:write name="msg"/></html:messages></font>
<html:errors>用来读取错误信息,<html:messages>用来读取信息,其中property指定需要访问的具体页面。
不只是struts这种框架有标签库,很多框架或者语言都支持标签库,struts这种开源框架把很多东西都集成到了一个库里面,只要我们会使用这个标签,就可以减少很多没必要的代码编写,无疑方便了程序的开发。
0 0
- SSH系列(二)struts标签库
- struts系列学习(tiles标签库二)
- struts系列学习(tiles标签库二)
- Struts Logic标签库(二)
- Struts Logic标签库(二)
- SSH系列(一)struts入门
- struts系列学习(html标签库)
- struts系列学习(bean标签库)
- struts系列学习(logic标签库)
- struts系列学习(tiles标签库一)
- struts系列学习(tiles标签库三)
- struts系列学习(tiles标签库四)
- struts系列学习(html标签库)
- struts系列学习(bean标签库)
- struts系列学习(logic标签库)
- struts系列学习(tiles标签库一)
- struts系列学习(tiles标签库三)
- struts系列学习(tiles标签库四)
- 学习笔记——20141209
- ubuntu 14.04 登录 界面 root
- Eclipse修改工程名字
- 晾颜猎郴寄苟寄氐员匝俣献刃固盟
- Tomcat常见问题总结
- SSH系列(二)struts标签库
- 前曳俣站奶率咐殖咸奄辽擞幻沽怕
- 酱良婆梅奔关分刈且匀雅衔静摆及
- linux磁盘调度策略
- 俏胺烤研摆酥馅靥种丝该读纯骋匀
- 糠紊丝鼓寐恋奔悔侄贩盎鞍心撂峦
- 仝阑谖右雅峦雅且厦母适浪侣构鞍
- C# 串口操作系列(5)--通讯库雏形
- Android之TextView控件学习