[英]How to get url path from jsp in Spring MVC framework
To remove the language toggle from the page view(Comfirmation Page)从页面视图中删除语言切换(确认页面)
I found this code but it doesn't work in Spring MVC我找到了这段代码,但它在 Spring MVC 中不起作用
<c:if test="${!fn:contains(pageContext.request.servletPath,'/comfirmation')}">
//Other Code
</c:if>
Finally, I got it.最后我得到了它。 Here we go
这里我们 go
<%
String url=request.getAttribute("javax.servlet.forward.servlet_path").toString();
if(url.equals("/Confirmation.htm")){
%>
//Language Toggle code
<% } %>
I decided to use this.我决定用这个。 Another way is that storing url path in session since front controller.
另一种方法是将 url 路径存储在 session 中,因为前面是 controller。
the pageContext.request.servletPath
will give you the path of the jsp (and not the url your browser shows). pageContext.request.servletPath
将为您提供 jsp 的路径(而不是浏览器显示的 url)。
The request is forwarded to a controller, which returns a path to a view.请求被转发到 controller,它返回视图的路径。 The view ist called using a second internal request
使用第二个内部请求调用视图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.