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

Spring JSTL form tag removes context path if servletRelativeAction starts with context path [SPR-16617] #21158

spring-projects-issues opened this issue Mar 20, 2018 · 0 comments


Copy link

@spring-projects-issues spring-projects-issues commented Mar 20, 2018

Brett Ryan opened SPR-16617 and commented

Using the spring jstl form tag attribute servletRelativeAction with a value that starts with the context path strips off this from the value rendered.

Steps to Reproduce

  1. Create a new webapp deployed at location /foo with a spring MVC context mapped to /
  2. Create a form JSP using the following content ```html
    <%@ page pageEncoding="UTF-8" trimDirectiveWhitespaces="true" %>
    <%@ taglib uri="" prefix="form" %>
    <form:form servletRelativeAction="/foo/my-action" method="POST">
    <form:form servletRelativeAction="/bar/my-action" method="POST">
1. Create a mapping to the above form and observe the output.

# Expected Behavior

Form should render as follows:

<form id="command" action="/foo/foo/my-action" method="POST">
<form id="command" action="/foo/bar/my-action" method="POST">

Actual Behavior

Form is actually rendered without the leading context path for the first form entry:

<form id="command" action="/foo/my-action" method="POST">
<form id="command" action="/foo/bar/my-action" method="POST">


Do not use the spring JSTL form implementation and instead use <c:url value="/"/> to provide the output context path.

<%@taglib prefix="c" uri="" %>
<form action="<c:url value="/foo/my-action"/>" method="POST">

Alternatively using the spring <form:form> implementation use the action attribute by providing the pageContext's context path:

<form:form action="${pageContext.request.contextPath}/foo/my-action" method="POST">

Affects: 5.0.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant