问答详情
源自:2-2 Struts2 案例代码实现

”执行Action“字符串出现,但是不跳转

也是404错误还说No result defined for action action.HelloAction and result success。有人遇到相同问题吗

提问者:石头子0 2016-04-11 14:12

个回答

  • 石头子0
    2016-04-11 14:26:04

    解决了,return SUCCESS;相当于return “success”;

    struts.xml改成<result name="success">/index.jsp</result>

  • 石头子0
    2016-04-11 14:14:27

    HelloAction.java

    package action;


    import com.opensymphony.xwork2.ActionSupport;


    public class HelloAction extends ActionSupport {

    /**

    */

    private static final long serialVersionUID = 1L;

    @Override

    public String execute() throws Exception {

    System.out.println("执行Action");

    return SUCCESS;

    }


    }


  • 石头子0
    2016-04-11 14:13:50

    struts.xml

    <?xml version="1.0" encoding="UTF-8"?>

    <!DOCTYPE struts PUBLIC

    "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"

    "http://struts.apache.org/dtds/struts-2.3.dtd">

    <struts>

    <package name="default" namespace="/" extends="struts-default">

    <action name="HH" class="action.HelloAction">

    <result>/index.jsp</result>

    </action>

    </package>

    </struts>