第一、學習struts2標簽文檔的順序
struts2標簽語法
struts-2.0.11.2/docs/docs/tag-syntax.html
OGNL語法
struts-2.0.11.2/docs/docs/ognl.html
標簽參考
struts-2.0.11.2/docs/docs/tag-reference.html
第二、容易搞混的符號:
%{...}: 顯示地表示表達式
#: 調用非根的上下文map中的值,如#request, #session, #attr等
@: 調用靜態方法或者靜態屬性
'': 用來表示字符串常量
"": html元素屬性值
舉例:
調用靜態屬性:
<s:property value="@全類名@serialVersionUID"/>
調用靜態方法:
<s:property value="@全類名@sayHello()"/>
第三、使用debug調試標簽
<s:debug/>
第四、action的測試junit測試用例的編寫方法
新建action
填入參數
執行action方法,比如execute()
assert輸出結果
第五、自定義struts2標簽
AbstractUITag
ComponentTagSupport
HiddenTag
Hiddeng
ftl模塊文件