首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

struts2 中转

2012-10-25 
struts2 转发struts2中转发:类ActionForward中的代码package com.luhua.actionimport com.opensymphony.x

struts2 转发
struts2中转发:

   类ActionForward中的代码  

   package com.luhua.action;

  import com.opensymphony.xwork2.ActionSupport;

   public class ActionForward extends ActionSupport{

private static final long serialVersionUID = 1L;

public String execute(){

return "success" ;

}

   }

   1.从action到页面
      struts.xml的配置如下:
         
    <package name="default" namespace="/forward" extends="struts-default">
        <default-action-ref name="index" />
     
        <action name="first" method="execute" >
        <result name="success" >/WEB-INF/page/index.jsp</result>
        </action>
       
    </package>
  

   /WEB-INF/page/index.jsp 这里WEB-INF前面必须加上/ ,
 


   2.同一包中,action跳action

    <package name="default" namespace="/forward" extends="struts-default">
        <default-action-ref name="index" />
     
        <action name="first" method="execute" >
        <result name="success" >/WEB-INF/page/index.jsp</result>
        </action>
        <action name="forward" method="execute" >
        <result name="success" type="redirectAction">/first</result>
        </action>
       
    </package>

   /first 这里可以加/可以不加,

热点排行