Skip to content

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

Closed
spring-projects-issues opened this issue Sep 12, 2011 · 5 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Sep 12, 2011

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:

<form:form method="post" action="/registration/submit" commandName="registrationForm" resolveContext="true" resolveMapping="true">
  ...
</form:form>

If you agree I am happy to implement :-)

Cheers.


Affects: 3.1 M2

Reference URL: https://jira.springsource.org/browse/SPR-8638

Issue Links:

Referenced from: commits ad025b5

@spring-projects-issues
Copy link
Collaborator Author

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.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 1, 2011

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).

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Dec 1, 2011

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>

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

The Form tag now fills in the context and servlet path if not present in the specified action.

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented May 10, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants