JSP的代碼模板(java 版)

        在通常性應用中,JSP負責頁面渲染的工做(將java對象渲染成爲html),JSP的代碼模板以下(使用java,從此博文將推出JSTL版):html

<%
xx=[request|session|application].getAttribute("key");  //須要向下鑄型
//xx 如爲非集合對象
out.print("html標籤開始");
out.print(xx.屬性1);
out.print(xx.屬性2);
out.print("html標籤結束");
//xx如爲集合屬性
for(T t:xx){
out.print("html標籤開始");
out.print(t.屬性1);
out.print(t.屬性2);
out.print("html標籤結束")
}
%>

 

此方法能夠解決全部複雜對象的渲染工做,但缺點是代碼太煩索,須要將html也進行輸出。java

相關文章
相關標籤/搜索