人生若只如初見,何事秋風悲畫扇。
In life there are very rare chances that you'll meet the person you love and loves you in return. So once you have it don't ever let go, the chance might never come your way.
剛剛才發現原來在JSP頁面,當用到其腳本,如在<%=REG%>表達式中,原來REG是可以直接從此JSP頁面的STRUTS中定義而來! 從bean標簽中引用,比如:
看struts參考文檔中,bean:define 是指定義一個在指定范圍內bean相關屬性的腳本變量(Define a scripting variable based on the value(s) of the specified bean property) 此中,person可能是在request等中預先已經定義好的DTO等等(這里暫時不是我們所要關注的啦),然后直接引用:
PrintUtil與UtilDateDTO均是在JSP頁面預先包含進來的(也不用關注),這些都是后臺部分的處理了,這里主是說明在JSP中其腳本如何引用STRUTS標簽中的變量值。 也可以直接從logic中引用,如:
其原理一樣的。?????????logic:iterate是用來迭代指定范圍內一些特定的集合容器(Custom tag that iterates the elements of a collection, which can be either an attribute or the property of an attribute. The collection can be any of the following: an array of objects, an Enumeration, an Iterator, a Collection (which includes Lists, Sets and Vectors), or a Map (which includes Hashtables) whose elements will be iterated over.) 應用示例: 在DTO中我的一屬性---生日,在實體與DTO均定義為Long,所以假如有一個為1950-01-01生日的數據,那么在DTO與實體中就表示為631124235983
當然這樣在JSP中加了個<%=%>符號,要不就在DTO中額外為生日另一個屬性提供對生日的字符顯示("yyyy-MM-dd")。 在JSP中恰當應用相關標簽,不僅編程方便,而且代碼也可以美觀不少。
Powered by: BlogJava Copyright © Jkallen