开发者

how to redirect struts2 action to a url after validation?

I have a action with a url creation like this

if (this.sequence.equals("") ) {
       action= "input";
   } else {url = "/files/" + testHTML.getName();
         action= "redirect";

    }
   开发者_StackOverflow   return action;

in my struts.xml my action is declarated has

        <interceptor-ref name="completeStack"/>
        <interceptor-ref name="execAndWait">
            <param name="delaySleepInterval">500</param>
        </interceptor-ref>
        <result name="wait">testwait.jsp</result>
        <result name="input">test.jsp</result>
         <result name="redirect" type="redirect">${url}</result>
    </action>

When I launch the application, the url is created but there are no redirection to this new page but to the test.jsp page and I have the validation error message that appear. Anybody have some idea?


Your original code example looks correct. Here are a few things to check:

  • Does your action have a getUrl() method? The ${url} part of the result relies on that method to get the url property.
  • Have you verified that the correct result is returned in each case? e.g., 'redirect' in the else block and 'input' otherwise.


if you are using validate method and if there is validation errors struts return result name="input". In your case put redirect in

     <result name="input" type="redirect">${url}</result>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜