Skip to content
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

Form tag should prepend the contextPath and servletPath if not present [SPR-8684] #13326

Closed
spring-issuemaster opened this issue Sep 12, 2011 · 5 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster 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:

  • #11609 Prepend contextPath in form tag ("duplicates")
  • #10449 Allow links to @Controller methods from views without hardcoding URLs
  • #15015 Form tag prepending context/servlet path breaks use for portlets

Referenced from: commits ad025b5

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Sep 13, 2011

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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster 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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster 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-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 14, 2013

Rossen Stoyanchev commented

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

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.