简体   繁体   English

重定向操作导致struts2无法正常工作

[英]redirect action result in struts2 not working

<action name="doLogin" class="controller.LoginAction">
    <result name="input">login.jsp</result>
    <result name="error">login.jsp</result>
    <result name="success" type="redirectAction">
        <param name="actionName">doStartIndex</param>
    </result>
    <result name="adminpage" type="redirect">adminPage.jsp</result>
</action>

<action name="doStartIndex" class="controller.IndexingAction" method="autoAllocate">
    <result>home.jsp</result>
</action>

NOTE: I'm using struts2.2.1 注意:我正在使用struts2.2.1

by using this i'm trying to move from one action to another but I get the following 404: 通过使用此方法,我试图从一个动作转到另一个动作,但得到以下404消息:

localhost:80801/ai/ 本地主机:80801 / ai /
The requested resource (/ai/) is not available. 所请求的资源(/ ai /)不可用。

In one of my scenario I was in need of creation a bean class but since the action class has the same bean elements that which I want to create in my new bean class except the parameterized constructor. 在我的一种情况下,我需要创建一个bean类,但是由于该动作类具有与我要在新bean类中创建的相同的bean元素,除了参数化的构造函数。

So I was testing to use the action class inserted to creating a new bean class. 因此,我正在测试使用插入的动作类来创建新的bean类。 First I was wrong that an action class can also have parameterized constructor and while I tried to work with that my action, it fails to work and returns to the same page where I initiated that action and even I did not get any stack trace too. 首先,我错了,一个动作类也可以具有参数化的构造函数,并且当我尝试使用该动作时,它无法正常工作,并返回到启动该动作的同一页面,甚至我也没有得到任何堆栈跟踪。

So People keep remember that we should not try to create parameterized constructor for an action class with out creating a default constructor. 因此,人们始终牢记,我们不应该在没有创建默认构造函数的情况下为动作类创建参数化构造函数。 I hope about this last line I'm correct if I need any correction please correct me. 我希望这最后一行是正确的,如果我需要任何更正,请纠正我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM