I have a problem with a site on struts2.
First I developed the site on http://localhost:8080/site
Then QA team deployed it to http://testmachine/site - all worked ok.
Then QA created http://sub.anotherdomain.com that pointed to http://testmachine/site - and that is where problems began.
I notice that all links was like http://sub.anotherdomain.com/site/some.action - it means that the real path link was pointing to was http://testmachine/site/site/some.action which was wrong.
The struts tag included the webapp context path (/site) which was the place the site actually deployed.
I found the way to work only on http://sub.anotherdomain.com/ or on http://testmachine/ (root context) with same way. I changed the includeContext="false" on all s:url tags. But that is not working with s:form that is still includes context information in action="sendMail.action".
1. How to have my site working both on http://testmachine/site and http://sub.anotherdomain.com/ >pointed to>http://testmachine/site
2. How to have <s:form action="sendMail.action" method="get" theme="simple"> pointed to http://sub.anotherdomain.com/sendMail.action but not on http://sub.anotherdomain.com/site/sendMail.action ??
The form tag will include the application context, whether it's an empty string or an actual context--I'm not sure what problem you're actually having. Maybe the problem is that you're including the ".action" in the form tag, which is neither necessary, nor a good idea.
Joined: Apr 16, 2010
Hello again David - I believe I'm having the same problem that Mike Nason did.
Briefly stated, I'm trying to use a Struts2 form tag in an application which is deployed in an app in a WebLogic container, which is "front-ended" by a high-performance web server.
The server drives mapped URL requests back to my app using some re-writing rules -- so even though I've deployed my app with the context of MyApp, it brokers requests to a "jsp" folder at the root of the domain back to the application for handling.
The problem comes in when I use the <s:form> tag to set up a form pointing back to an action. I need the output of:
I see how having the Struts2 <s:form /> tag automatically prepend the context path would be useful, but like Mike Nason, I'm trying to find a way to prevent it. Is there an attribute in the tag that I'm misunderstanding, or a struts.xml value I need to enable?