1.Struts标签 http://www.iteye.com/topic/251411
2.Struts代码
标记赋值:
<html:hidden property="property" value='' />
解析HTML标记
<bean:write name="node_id" property="content" filter="false"/>
格式时间
<bean:write name="node_id" property="createDate" format="yyyy年MM月dd日 HH:mm:ss" />
3.Struts标签配置 http://www.iteye.com/topic/333898
配置Struts标签库:
1、在struts-config.xml文件中加入:<message-resources parameter="MessageResources"/>
2、拷贝MessageResources.properties到项目的Src下;
标签<bean:write />的属性
3、属性filter:
a)、 action中存储,request.setAttribute("bj", "<font color='red'>北京欢迎您</font>");
b)、jsp中获取, 格式化后输出:<bean:write name="bj" filter="false"/>
c)、jsp中获取,原样输出: <bean:write name="bj" filter="true"/>
4. 属性format:
====日期======
Action中设置日期:
request.setAttribute("today", new Date());
jsp中显示:
<%=request.getAttribute("today") %> 输出:Mon Jan 05 23:17:43 CST 2008
<bean:write name="today" format="yy-MM-dd HH:mm:ss"/> 输出:09-01-05 23:17:43
====数字======
Action中设置数字:request.setAttribute("n", 124567.45);
jsp中显示:
<bean:write name="n"/>
输出:124567.45
<bean:write name="n" format="###,###.000"/>
输出:124,567.450
5.属性property
Action中设置对象:
User user=new User();
user.setUsername("wulihai");
user.setAge(25);
Group group=new Group();
group.setName("地下党");
user.setGroup(group);
request.setAttribute("user", user);
jsp中显示:
<input type="text" value="<bean:write name="user" property="username"/>"/>
输出:wulihai
<input type="text" value="<bean:write name="user" property="group.name"/>"/>
----group.name导航输出为:地下党
6.<bean:write /> 标签是服务器端脚本,在服务器端执行,所以可以直接在将其值付给客户端标签input的value属性,不用加转义符"\",
例如上面:<input type="text" value="<bean:write name="user" property="username"/>"/>
7.<logic:empty>,<logic:notEmpty>,<logic:iterate>
例如:
====Action存储数据:==========
List userList=new ArrayList();
for(int i=0;i<10;i++){
Group group=new Group();
group.setName("投名状_"+i);
User user=new User();
user.setAge(25+i);
user.setUsername("电驴_"+i);
user.setGroup(group);
userList.add(user);
}
request.setAttribute("userList", userList);
.......................
............................................
========jsp页面:==============
<table border="1">
<tr>
<td>姓名</td>
<td>年龄</td>
<td>所属组</td>
<tr>
<logic:empty name="userList">
<tr>
<td colspan="3">没有成员</td>
<tr>
</logic:empty>
<logic:notEmpty name="userList">//userList不为空,则进行迭代
<logic:iterate id="u" name="userList">// 此处的id属性代表的就是name中的元素,此处也就是userList中的每一个User对象;
<tr>
<td><bean:write name="u" property="username"/></td>
<td><bean:write name="u" property="age"/></td>
<td><bean:write name="u" property="group.name"/></td>
<tr>
</logic:iterate>
</logic:notEmpty>
</table>
2.Struts代码
标记赋值:
<html:hidden property="property" value='' />
解析HTML标记
<bean:write name="node_id" property="content" filter="false"/>
格式时间
<bean:write name="node_id" property="createDate" format="yyyy年MM月dd日 HH:mm:ss" />
3.Struts标签配置 http://www.iteye.com/topic/333898
配置Struts标签库:
1、在struts-config.xml文件中加入:<message-resources parameter="MessageResources"/>
2、拷贝MessageResources.properties到项目的Src下;
标签<bean:write />的属性
3、属性filter:
a)、 action中存储,request.setAttribute("bj", "<font color='red'>北京欢迎您</font>");
b)、jsp中获取, 格式化后输出:<bean:write name="bj" filter="false"/>
c)、jsp中获取,原样输出: <bean:write name="bj" filter="true"/>
4. 属性format:
====日期======
Action中设置日期:
request.setAttribute("today", new Date());
jsp中显示:
<%=request.getAttribute("today") %> 输出:Mon Jan 05 23:17:43 CST 2008
<bean:write name="today" format="yy-MM-dd HH:mm:ss"/> 输出:09-01-05 23:17:43
====数字======
Action中设置数字:request.setAttribute("n", 124567.45);
jsp中显示:
<bean:write name="n"/>
输出:124567.45
<bean:write name="n" format="###,###.000"/>
输出:124,567.450
5.属性property
Action中设置对象:
User user=new User();
user.setUsername("wulihai");
user.setAge(25);
Group group=new Group();
group.setName("地下党");
user.setGroup(group);
request.setAttribute("user", user);
jsp中显示:
<input type="text" value="<bean:write name="user" property="username"/>"/>
输出:wulihai
<input type="text" value="<bean:write name="user" property="group.name"/>"/>
----group.name导航输出为:地下党
6.<bean:write /> 标签是服务器端脚本,在服务器端执行,所以可以直接在将其值付给客户端标签input的value属性,不用加转义符"\",
例如上面:<input type="text" value="<bean:write name="user" property="username"/>"/>
7.<logic:empty>,<logic:notEmpty>,<logic:iterate>
例如:
====Action存储数据:==========
List userList=new ArrayList();
for(int i=0;i<10;i++){
Group group=new Group();
group.setName("投名状_"+i);
User user=new User();
user.setAge(25+i);
user.setUsername("电驴_"+i);
user.setGroup(group);
userList.add(user);
}
request.setAttribute("userList", userList);
.......................
............................................
========jsp页面:==============
<table border="1">
<tr>
<td>姓名</td>
<td>年龄</td>
<td>所属组</td>
<tr>
<logic:empty name="userList">
<tr>
<td colspan="3">没有成员</td>
<tr>
</logic:empty>
<logic:notEmpty name="userList">//userList不为空,则进行迭代
<logic:iterate id="u" name="userList">// 此处的id属性代表的就是name中的元素,此处也就是userList中的每一个User对象;
<tr>
<td><bean:write name="u" property="username"/></td>
<td><bean:write name="u" property="age"/></td>
<td><bean:write name="u" property="group.name"/></td>
<tr>
</logic:iterate>
</logic:notEmpty>
</table>