
??????也就是由于駕照的事,很久沒有來更新了,一周前學(xué)習(xí)了Struts的Tiles框架,到現(xiàn)在才寫心得。。。
??????首先,要實(shí)現(xiàn)Tiles框架,得創(chuàng)建一個(gè)描述網(wǎng)站布局的jsp文件,在文件中,導(dǎo)入struts-tiles.tld文件,對(duì)嵌入其他jsp文件的地方,使用<tiles:insert>標(biāo)記,如:
??????<tiles:insert attribute="content" ></tiles:insert>
??????attribute屬性指定的名稱是要插入的文件的邏輯名字,具體的現(xiàn)實(shí)名稱要到相關(guān)的XML文件中制定。
??????接著創(chuàng)建一些相關(guān)的,將要插入到Tiles框架中的jsp文件,并且創(chuàng)建XML文件,在XML文件中對(duì)attribute進(jìn)行配置。
??????最后將xml文件插入到工程中,這需要在struts-config.xml文件進(jìn)行配置:
? <plug-in className="org.apache.struts.tiles.TilesPlugin" >
? ?<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
? ?<set-property property="definitions-parser-validate" value="true" />
? </plug-in>
并且在創(chuàng)建的jsp文件中使用<tiles:insert definition="index-definition" ></tiles:insert>,從而將組件插入到網(wǎng)頁當(dāng)中,實(shí)現(xiàn)Tiles框架!