Struts bean:define標(biāo)簽用法
Struts bean:define標(biāo)簽用法
一是定義新字符串常量:
<bean:define id="foo" value="This is a new String"/>
<bean:define id="bar" value='<%= "Hello, " + user.getName() %>'/>
<bean:define id="last" scope="session" value='<%= request.getRequestURI() %>'/>
二是復(fù)制一個(gè)現(xiàn)有的bean給新的bean:
<bean:define id="foo" name="bar"/>
<bean:define id="baz" name="bop" type="com.mycompany.MyClass"/> //定義腳本變量的類(lèi)型,默認(rèn)為Object
三是復(fù)制一個(gè)現(xiàn)有的bean的屬性給新的bean:
<bean:define id="bop" name="user" property="role[3].name"/>
<bean:define id="foo" name="bar" property="baz" scope="request" toScope="session"/>
//toScope屬性指新bean的scope,默認(rèn)為page
上段代碼的意思是把名為bar的bean的baz屬性賦值給foo,foo的類(lèi)型為String(默認(rèn))。
一是定義新字符串常量:
<bean:define id="foo" value="This is a new String"/>
<bean:define id="bar" value='<%= "Hello, " + user.getName() %>'/>
<bean:define id="last" scope="session" value='<%= request.getRequestURI() %>'/>
二是復(fù)制一個(gè)現(xiàn)有的bean給新的bean:
<bean:define id="foo" name="bar"/>
<bean:define id="baz" name="bop" type="com.mycompany.MyClass"/> //定義腳本變量的類(lèi)型,默認(rèn)為Object
三是復(fù)制一個(gè)現(xiàn)有的bean的屬性給新的bean:
<bean:define id="bop" name="user" property="role[3].name"/>
<bean:define id="foo" name="bar" property="baz" scope="request" toScope="session"/>
//toScope屬性指新bean的scope,默認(rèn)為page
上段代碼的意思是把名為bar的bean的baz屬性賦值給foo,foo的類(lèi)型為String(默認(rèn))。
快快樂(lè)樂(lè)、認(rèn)認(rèn)真真生活才是真。
posted on 2009-03-23 16:11 鮑佩 閱讀(2064) 評(píng)論(0) 編輯 收藏