首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

Struts+spring+hibernate 框架,当需要在Action类中转向一个Action(.do的请求)时,如何处理?

2011-12-17 
Struts+spring+hibernate 框架,当需要在Action类中转向一个Action(.do的请求)时,怎么处理??public ActionF

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试试

热点排行