Struts+spring+hibernate 框架,当需要在Action类中转向一个Action(.do的请求)时,怎么处理??
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
EmployyInfoEditForm employyInfoEditForm = (EmployyInfoEditForm) form;
Employee employee = new Employee();
if(request.getParameter("method").equals("savesuccess")){
setEmployeeData(employee,employyInfoEditForm);
employeeService.getEmployeeDAO().save(employee);
ActionForward nextPage = new ActionForward();
nextPage.setName(""preAdd");
nextPage.setPath("/educateEdit.do");
return nextPage;
}
====struts-config.xml部分相关配置
<action-mappings >
<action name="employyInfoEditForm" attribute="employyInfoEditForm"
parameter="method" path="/employyInfoEdit"
scope="request" type="com.hrs.struts.action.EmployyInfoEditAction" >
<forward name="savesuccess" path="/WEB-INF/pages/employyInfoList.jsp"/>
</action>
<action name="
educateEditForm" parameter="method" path="/educateEdit"[b][/b] scope="request"
type="com.hrs.struts.action.EducateEditAction">
<forward name="preAdd" path="/WEB-INF/pages/educateAdd.jsp"/> </action>
为什么转不到 /WEB-INF/pages/educateAdd.jsp这个页面上???跳转后出现空白,也没有抛错。。
------解决方案--------------------
Java code
你用的是struts2.x吧 这个不熟悉 但是在struts1.x中
forward默认的属性是false是 跳转不是重定向。不知道记错没,跳转不能到WEB/INF目录的,必须是重定向
即
在<action 中加入属性redirect = "true"
redirect属性可选,默认值false,表示以转发的方式执行forward,如果为true则以redirect的方式执行forward
------解决方案--------------------
/educateEdit.do?method=xxx试试