您的位置:首页 > 编程语言 > Java开发

struts学习笔记6

2012-03-02 16:53 183 查看
struts提供了三大常用标签库:html,bean,logic

html标签:用来代替普通标签,支持自动回填功能(出错时可以回填,修改时设置默认值也可以回填)

bean标签:显示数据到页面上,支持设置属性功能,支持国际化

login标签:循环判断功能

1.logic标签

判断标签一共6组,12个:

logic:present,logic:notPresent:判断某个属性是否存在

logic:equal,logic:notEqual:判断属性是否等于或不等于某个值

logic:greaterThan,logic:lessThan:判断属性大于或小于某个值

logic:empty,logic:notEmpty:判断某个属性值是否为空

logic:match,logic:notMatch:判断属性是否匹配某一个字符串

logic:iterate:循环迭代某个集合属性

2.bean标签

可以通过bean:define,bean:include,bean:size等向属性范围中临时设置属性。(一般不用)

需要记住的标签:

bean:write:功能与EL类似,用来将属性显示到页面上。可以过滤非法字符。

<bean:write name="news" property="content"/>

而且支持日期和金额的格式化显示。

<bean:write name="news" property="postDate" format="yyyy-MM-dd"/>

<bean:write name="money" format="¥,##0.00"/>

bean:message标签可以取得属性文件中的内容,并显示到页面上。主要用来完成国际化功能。

3.html标签

Html标签

普通表单

表单

Html:form

只能提交.do路径(只能进入Action)

默认提交方式是post

自动验证提交路径是否存在

<form>

可以提交任意路径。

默认提交方式为get

无论路径是否存在,表单都可以显示。

功能相同的标签

<html:button>

<html:submit>

<html:reset>

<html:image>

两者使用上没有区别,<html:>标签必须在<html:form>中使用

<input type=”button”>

<input type=”submit”>

<input type=”reset”>

<intpu type=”image”>

可以在任意表单中使用

输入类标签

<html :text>

<html :password>

<html :textarea>

<html:hidden>

参数名使用property=””来定义

使用styleId

使用styleClass

支持回填

<input type=”text”>

<input type=”password>

<textarea></textarea>

<input type=”hidden”>

参数名使用 name=””定义

使用id

使用class

不支持回填”

单选按钮

<html:radio>

通过回填功能设置默认选中

<input type=”radio”>

使用checked属性设置默认选中

下拉列表

<html:select>

<html:option>

默认选中通过回填

支持直接将List集合转化机为下拉列表的功能。

<html:options>或<html:optionCollection>都可以实现。

<select>

<option>

默认选中使用selected

多选框

<html:checkbox>

不支持默认选中

<html:multibox>

支持默认选中(通过回填)

<inputtype=“checkbox”>

默认选中使用checked

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: