如何在jsp中的浏览器中获取路径 [英] How to get path at browser in jsp

查看:176
本文介绍了如何在jsp中的浏览器中获取路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是基本问题.但是我不明白如何得到它. 我的浏览器URL是http://testweb/edit.htm'. testweb是上下文路径.这个uri来自Spring.我需要在我的jsp中获取edit.htm,它位于上下文之后.如何获得这个.谢谢您的支持

May be this is the basic Question. But i am not able to understand how to get it. My browser url is http://testweb/edit.htm'. testweb is context path. This uri is from Spring. I need to get edit.htm which is after context, in my jsp. How to get this. Thank you for the support

谢谢, 珊莎/

推荐答案

HttpServletRequest 提供了几种访问请求URL(的一部分)的方法,其中包括也就是说,该工作应该FilterServlet而不是JSP文件.

That said, this job should be done in a Filter or maybe a Servlet rather than a JSP file.

更新:您似乎正在使用Spring,而对调用转发的JSP的请求URI感兴趣.您可以使用键 如下:

Update: you seem to be using Spring and rather be interested in the request URI which called the forwarded JSP. You can get it as request attribute with the key RequestDispatcher#FORWARD_REQUEST_URI as follows:

String uri = request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);

或在JSP EL中如下所示:

or in JSP EL as follows:

${requestScope['javax.servlet.forward.request_uri']}

这篇关于如何在jsp中的浏览器中获取路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆