jsp - Servlet path is not included in <c:url> -
i have simple java webapp (eg. test
) containing 2 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 web part i'm using "classic" libraries, such jstl core.
i don't understand how avoid jstl c:url
tag ignoring url pattern.
if write
<c:url value="/browse/"/>
the link rendered /test/browse
, not /test/web/browse
.
what i'm missing?
thank you
the <c:url>
indeed not take servlet path account. that's own responsibility. <c:url>
takes httpservletrequest#getcontextpath()
account.
either hardcode yourself:
<c:url value="/web/browse" />
or inline result of httpservletrequest#getservletpath()
:
<c:url value="${pagecontext.request.servletpath}/browse" />
or if you're forwarding, inline result of requestdispatcher#forward_servlet_path
:
<c:url value="${requestscope['javax.servlet.forward.servlet_path']}/browse" />
wrap if necessary in custom tag save boilerplate.
Comments
Post a Comment