jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes Struts 2  struts.xml not redirecting  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2  struts.xml not redirecting  " Watch "Struts 2  struts.xml not redirecting  " New topic
Author

Struts 2 struts.xml not redirecting

Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 102

Hello,
When I try

http://localhost:8080/Mypage/Prepost

The application is redirected to the default action by?

Here is my struts.xml
<CODE>

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
<package name="Mypage" namespace="/" extends="struts-default">
<default-action-ref name="Home" />


<action name="Register" class="action.Register" method="execute">
<result name="success">/jsp/register_finish.jsp</result>
<result name="input">/jsp/register.jsp</result>
</action>

<action name="PrePost" class="action.PrePost" method="execute">
<result name="success">/jsp/submit.jsp</result>
<result name="error">/jsp/submit_unautoried.jsp</result>
</action>

<action name="Home" class="action.Home" method="execute">
<result name="success">/jsp/home.jsp</result>
</action>

<action name="Upload" class="action.Upload" method="execute">
<result name="success">/jsp/submit.jsp</result>
</action>

<action name="Post" class="action.Post" method="execute">
<result name="success">/jsp/post_finish.jsp</result>
<result name="error">/Mypage/Home</result>
<result name="input">/jsp/submit.jsp</result>
<interceptor-ref name="defaultStack">
<param name="fileUpload.allowedTypes">image/*</param>
<param name="fileUpload.maximumSize">10240</param>
</interceptor-ref>
</action>

<action name="Login" class="action.Login" method="execute">
<result name="success">/jsp/home.jsp</result>
</action>

</package>
</struts>

</CODE>

Why it's not being redirected the Prepost action?

Thanks in advance.


Nitin Surana
Ranch Hand

Joined: Jan 21, 2011
Posts: 129

Try

http://localhost:8080/Mypage/Prepost.action

instead of

Fernando Dominguez wrote:Hello,

http://localhost:8080/Mypage/Prepost

Mohana Rao Sv
Ranch Hand

Joined: Aug 01, 2007
Posts: 485

Hi Nitin, but struts will add .action extension by default it doesn't make difference you are calling the action by it's name directly or by adding extension. After careful observation i got It's PrePost not Prepost
http://localhost:8080/Mypage/PrePost try this.


ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Fernando Dominguez
Ranch Hand

Joined: Sep 01, 2006
Posts: 102

You are right.
Thanks.
 
Consider Paul's rocket mass heater.
 
subject: Struts 2 struts.xml not redirecting