|
今天用OA项目,有一个链接没有设错,后来当真检查原来发现是因为重写一个方法重写错了。我把unspecified这个方法重写成了dispatchMethod
的方法。
原来代码为:
package com.bjsxt.oa.web.actions;
import javaServletservletJavaSErvletservletstrutsstrutsstrutsstrutsservletservletservletservletservletservletx..http.HttpRequest;
import x..http.HttpResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache..action.ActionForm;
import org.apache..action.ActionForward;
import org.apache..action.ActionMapping;
import org.apache..actions.DispatchAction;
import com.bjsxt.oa.managers.ModuleManager;
import com.bjsxt.oa.model.Module;
import com.bjsxt.oa.web.forms.ModuleActionForm;
public class ModuleAction extends DispatchAction {
private ModuleManager moduleManager;
@Override
protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
HttpRequest request, HttpResponse response)
throws Exception {
ModuleActionForm maf = (ModuleActionForm)form;
request.setAttribute("pm",
moduleManager.searchModules(maf.getParentId())
);
return mapping.findForward("index");
}
//打开添加界面
public ActionForward addInput(ActionMapping mapping, ActionForm form,
HttpRequest request, HttpResponse response)
throws Exception {
return mapping.findForward("add_input");
}
//添加模块
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpRequest request, HttpResponse response)
throws Exception {
ModuleActionForm maf = (ModuleActionForm)form;
int parentId = maf.getParentId();
Module module = new Module();
BeanUtils.copyProperties(module, parentId);
moduleManager.addModule(module, parentId);
return mapping.findForward("pub_add_success");
}
public void setModuleManager(ModuleManager moduleManager) {
this.moduleManager = moduleManager;
}
}
后来把dispatchMethod方法改成unspecified方法,链接就没有题目了。原来dispatchMethod是把Action接收到的哀责备部由自己来分发;而
unspecified则是把没有指定分发方法的哀求分发。 |
|