I have a simple Java Webapp (eg. test
) containing two different SpringMVC application.
My web.xml maps them as:
<servlet-mapping>
<servlet-name>web</servlet-name>
<url-pattern>/web/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>restful</servlet-name>
<url-pattern>/restful/*</url-pattern>
</servlet-mapping>
Inside the web part I'm using "classic" libraries, such as JSTL core.
I don't understand how to avoid JSTL c:url
tag ignoring the URL pattern.
If I write
<c:url value="/browse/"/>
the link is rendered as /test/browse
and not /test/web/browse
.
What I'm missing?
Thank you
The
<c:url>
does indeed not take servlet path into account. That's your own responsibility. The<c:url>
only takesHttpServletRequest#getContextPath()
into account.Either hardcode yourself:
Or inline result of
HttpServletRequest#getServletPath()
:Or if you're forwarding, inline result of
RequestDispatcher#FORWARD_SERVLET_PATH
:Wrap if necessary in a custom tag to save boilerplate.