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