Can struts 1.1 post to a relative path

2019-08-30 22:33发布

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>

标签: struts
1条回答
何必那么认真
2楼-- · 2019-08-30 22:52

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.

查看更多
登录 后发表回答