2013-07-01 38 views
1

我的任务是struts2的动作链接相关的动作名称[login.action],我的程序名称是chaining,我使用正确的语法,但它不起作用。动作链接错误:没有映射为命名空间操作[/]与上下文路径[/链接]

struts.xml中

<action name="register" class="RegisterAction"> 
    <result name="success" type="chain">login.action</result>  
</action> 
<action name="login" class="LoginAction" > 
    <result name="success">/login.jsp</result> 
</action> 

RegisterAction.java

public class RegisterAction { 

    public String execute() { 
     return "success";    
    } 
} 

LoginAction.java

public class LoginAction { 

    public String execute() { 
     return "success"; 
    } 
} 

但是当我运行程序时,它提供了以下错误发生

回答

2

从您的链接动作名称中删除后缀,从这个

<result name="success" type="chain">login.action</result> 

这个

<result name="success" type="chain">login</result> 

注意,不建议操作链接,重定向操作或者一些其他的方式应该是首选。

the official documentation

Don't Try This at Home
As a rule, Action Chaining is not recommended. First explore other options, such as the Redirect After Post technique.

看看这个答案过于:https://stackoverflow.com/a/4761955/1654265

相关问题