Struts 2配布
- <package name="showForum" namespace="/" extends="struts-default">
- <action name="showlist" method="{1}" class="forumAction">
- <result name="success" >/showForumList.jsp</result>
- <result name="ERROR">/error.jsp</result>
- </action>
- </package>
注意:class=forumActionはspringと統合されているため、spirng beanのidです.
- package com.bbs.action.forum;
-
- import java.util.List;
-
- import com.bbs.pojo.Forum;
- import com.bbs.services.ForumService;
- import com.opensymphony.xwork2.ActionContext;
-
- public class ForumAction {
- private int fkid;
- private ForumService fSerive;
-
- public int getFkid() {
- return fkid;
- }
-
- public void setFkid(int fkid) {
- this.fkid = fkid;
- }
-
- public ForumService getfSerive() {
- return fSerive;
- }
-
- public void setfSerive(ForumService fSerive) {
- this.fSerive = fSerive;
- }
-
- public String showForumList() {
- List<Forum> list = fSerive.getForumListByFkid(this.getFkid());
- ActionContext context = ActionContext.getContext();
- context.put("list", list);
- return "success";
- }
- }
リクエスト時に実行するメソッドがshowFormlist()である場合.
リクエストのアドレスは./actionName!methodName例:./showlits!/showForumList.action