-->

Can struts 1.1 post to a relative path

2019-08-30 21:59发布

问题:

I have a Struts application and I build by form

<html:form action="companyProvAdd"> ....</html:form>

which renders the html as

 <form name="companyProvAddForm" method="post" action="/ebig/companyProvAdd.do"> ...</form>

Is there a way to have the post go to a relative URL?

 <form name="companyProvAddForm" method="post" action="companyProvAdd.do"> ...</form>

回答1:

It looks like Struts 1.1 does not support this

https://issues.apache.org/jira/browse/STR-768

but I did find a workaround

<!-- <html:form action="companyProvAdd"> -->
<form name="companyProvAddForm" method="post" action="companyProvAdd.do">
....
</html:form>

The html:form tag is necessary because items in the form depend on its presence. Commenting it out keeps the browser from reading it and leaves room for the desired form line to be hard coded in.

It is an ugly hack, but it works.



标签: struts