Posted on 2010-05-22 23:56
Gavin.lee 閱讀(484)
評論(0) 編輯 收藏 所屬分類:
SSH2 --Struts2
1 利用腳本獲取傳入值:
在struts2中action傳遞給jsp中的數據是保存在OgnlValueStack中的,所以在jsp頁面中如果想利用腳本而不是sturts標簽獲取傳入值的話,盡量使用OgnlValueStack的值獲得,例如:
<%...OgnlValueStack stack = (OgnlValueStack) request.getAttribute("struts.valueStack");
Article article = (Article)(stack.findValue("article"));%>
2 sturts2標簽自動轉換Html標簽
在使用struts2標簽<s:property value="">來顯示傳遞值的時候,會將字符串中的html標簽轉換,所以可以利用java腳本直接獲取傳入值,使用方式見第一條