【struts标签】
bean:define
定义变量赋值有三种方式:
1。设置value属性,此时id属性定义的变量为字符串,value属性代表这个变量的字符串值。
<bean:defind id="userName" value="jing" />
UserName: <bean:write name="userName"/>
2。同时设置name和property属性。name属性指定一个已经存在的Bean。
Property属性指定已经存在的Bean的某个属性。id属性定义的变量的值由property属性决定。
<%request.setAttribute("sessionBean",session);%>
<bean:defind id="theSession" name="sessionBean" property="servletContext"/>
ServletContext Name: <bean:write name="theSession" property="servletContextName"/>
3。同时设置name和type属性。
<bean:defind id="loginBean" name="loginBean" type="com.jason.action.LoginBean"/>
<bean:write name="loginBean" property="password"/>
bean:size
用于获得Map,Collection的长度,id指定一个Integer类型的变量,name指定已经存在的map,collection或者数组。
<%
HashMap lines = new HashMap();
lines.put("1","Line 1");
lines.put("2","Line 2");
lines.put("3","Line 3");
request.setAttribute("lines",lines);
%>
<bean:size id="length" name="lines"/>
<bean:write name="length"/>
---------------摘自http://www.blogjava.net/gm_jing/articles/60004.html
本文详细解析了Struts框架中bean:define标签用于变量赋值的三种方式及bean:size标签用于获取Map、Collection的长度,并通过实例演示了如何使用。
1267

被折叠的 条评论
为什么被折叠?



