开发者

How to hide application context from urls?

开发者 https://www.devze.com 2023-01-21 03:43 出处:网络
I am using JSTL c:url tag to define my URL\'s in the application, something like: <c:url value\"/home\" />

I am using JSTL c:url tag to define my URL's in the application, something like:

<c:url value"/home" />

But the problem is that it appends the application context to the url, so the link becomes http://appName.come/appName/page while it should be http://appName.come/page.

The link had to be with slash, because it's not relative开发者_JS百科. I want to prevent the application context from being added or something like that, any ideas?


That's just the sole purpose of c:url: adding the context root and if necessary jsessionid whenever client doesn't support cookies. It also has support for URL-encoding the query parameters by c:param. If you don't want to have that, then just don't use c:url but use a plain HTML <a> element instead.

<a href="/home">home</a>

Update: as per the comment you seem to want to have the jsessionid in the URL (do you realize that the sessions are by default not shared between contexts and that you have to configure the serletcontainer accordingly?). In that case, manually set the context attribute.

<c:url context="/" value="/home" />
0

精彩评论

暂无评论...
验证码 换一张
取 消