Struts2點擊鏈接執行action方法

直接使用href=action即可:

無參數:

<a href=getJournals>日誌</a>

有參數:

<a href="getJournals?id=33&title=ttt">日誌</a>

所跳轉頁面可在struts.xml中配置:

<action name="getJournals" class="com.flowers.with.controler.Journals" method="obtainJournals">
 <result name="success">/WithView/journals.jsp</result>
</action>

另:

有參數需在action調用方法中增加:

private int id;
private String title;

並添加getters和setters方法。



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章