Struts Nested 標簽庫的一部分標簽用于表達 JavaBean 之間的嵌套關(guān)系,還有一部分標簽在特定的級別提供和其他Struts標簽庫的標簽相同的功能。其中最主要的兩個標簽為:"<nested:root>"和"<nested:nest>"。 1.<nested:nest>: 定義一個新的嵌套級別。<nested:nest> 標簽可以表達JavaBean之間的嵌套關(guān)系。<html:form action="/showPerson"> < nested:nest property="person"> LastName: < nested:text property="lastName"> < /nested:nest> < /html:form >以上的<nested:nest>標簽的上層JavaBean為與<html:form>表單標簽對應(yīng)的PersonForm Bean 。<nested:nest>標簽的property屬性為"person" ,代表PersonForm Bean 的person屬性。這個person屬性代表Person Bean , 因此嵌套在<nested:nest> 標簽內(nèi)部的Nested標簽都相對于這個Person Bean. 2.<nested:root>: 用來顯示的指定頂層級別的JavaBean。 <nest:root> 標簽的name屬性指定JavaBean的名字。嵌套在<nested:root>標簽中的<nested:nest>標簽的property屬性為這個JavaBean的某個屬性。<nested:root name="PersonForm"><nested:nest property="person"><nested:write property="lastName"/></nested:nest></nested:root>以上代碼中,<nested:root>標簽的name屬性"PersonFrom",代表當(dāng)前的PersonFormBean。 嵌套其中的<nested:nest>標簽的property屬性為"person",代表PersonForm Bean的person屬性。 參考文獻: 精通Struts: 基于MVC的Java Web 設(shè)計與開發(fā) |