- <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>
注: 由于和spring 整合,class= forumAction 是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";
- }
- }
如果请求时执行的方法的是showForumlist().
那么请求的地址就是./actionName!methodName 例:./showlits!/showForumList.action
转载于:https://blog.51cto.com/ningnian169/577248