开发者

Struts2 : Problem in redirecting From other site to myApplication

I am using struts2.0 and the application is deployed and tested over tomcat 6.0.

As per requirement, my application (myApplication) has to redirect from a PHP site with domain name http:// abc.com

When this PHP site redirects the request to my application it calls an action Action1 of my application, which further redirects to another action Action2. But while redirection it changes the domain name to Application's server IP (http://applicationServerIP:8080/myApplication/Action2 ). My expected result is ( http://abc.com/myApplication/Action2).

Action configuration in sturts.xml is:

<action name="Action1" class="Action1">
    <result name="success" type="redirectAction">Action2</result>
</action>

<action name="Action2" class="Action2">
    <result name="success">/myJSP.jsp</resu开发者_如何学Pythonlt>
</action>

Any Help to solve this issue will be appreciated.


By placing the following tag in /myJSP.jsp

<s:a>here</s:a> //I will write the current url as struts understands it.

Will show that struts will take the incoming url as the gospel in determining what the server name is.

So your application is being called with http://applicationServerIP:8080/myApplication/Action2 just change the call to http://abc.com/myApplication/Action2

If this is not what you want you'll need to change the URL before it reaches struts2. Some containers have built in support for this or an add-on/plug-in (I just use iptables).


You must bypass struts-config, because this only redirect to your own application, Try this:

public ActionForward method(ActionMapping mapping, ActionForm form,
                HttpServletRequest request, HttpServletResponse response){
       response.sendRedirect("http://www.example.com");
       return null;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜