-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Form tag should prepend the contextPath and servletPath if not present [SPR-8684] #13326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Rossen Stoyanchev commented We could consider a contextRelative="true" flag that would apply only if action is provided at all and if it starts with "/". For example see RedirectView and the Spring UrlTag. The servlet mapping is a bit more tricky and not always possible to determine the actual mapping in containers so I'm less keen on that. If you want to provide any code please consider adding the code via https://github.com/SpringSource/spring-framework-issues. |
Rossen Stoyanchev commented Having two attributes such as contextRelative and serlvetMappingRelative on every form tag doesn't seem like too much of an improvement. We may be able to decide whether to prepend the context path (and the servlet mapping) transparently recognizing that existing actions work either because they contain the context path already (e.g. with the help of <c:url var=".." value=".." />) or because they're relative paths. We'll revisit in 3.2 together with the related request #10449 and also in light of work done in 3.1 to build context-relative and serlvet-mapping relative URLs (#13465, #12675). |
Rossen Stoyanchev commented In the mean time see the fix for #13505: <form:form method="post" action="${requestContext.pathToServlet}/registration/submit" commandName="registrationForm">
...
</form:form> |
Rossen Stoyanchev commented The Form tag now fills in the context and servlet path if not present in the specified action. |
Rossen Stoyanchev commented Note that this change broke portlet applications (#15015). The change has been rolled back in 3.2.3. Instead there is there is a new form tag attribute called servletRelativeAction that must be used. |
Angel opened SPR-8684 and commented
Rossen,
in order to have this functionality available and be backward compatible at the same time could be having two additional paramters in the form tag:
If you agree I am happy to implement :-)
Cheers.
Affects: 3.1 M2
Reference URL: https://jira.springsource.org/browse/SPR-8638
Issue Links:
@Controller
methods from views without hardcoding URLsReferenced from: commits ad025b5
The text was updated successfully, but these errors were encountered: