1. 程式人生 > >Struts2中動態方法呼叫有三種方式

Struts2中動態方法呼叫有三種方式

Jsp中訪問方式
<body>
    <a href="basePath/chapter3/chapter3Action!result1">result1</a><br><ahref="basePath/chapter3/chapter3Action!result1">result1</a><br><ahref="{basePath}/chapter3/chapter3Action!result2">result2</a><br>
</body> 
如果配置了字尾,必須這樣寫:
/chapter4/chapter4Action!create.action
XML中配置方式
<package name="chapter3" namespace="/chapter3" extends="struts-default">
   <action name="chapter3Action" class="chapter3.action.Chapter3Action">
    <result name="result1">/WEB-INF/JspPage/chapter3/result1.jsp</result>
    <result name="result2">/WEB-INF/JspPage/chapter3/result2.jsp</result>
    <result name="chapter3">/WEB-INF/JspPage/chapter3/chapter3.jsp</result>
   </action>
</package>