如何在JSP中获取完整的URL [英] How to get full URL in JSP

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

问题描述

如何获取JSP页面的完整URL。

How would I get the full URL of a JSP page.

例如,URL可能是 http://www.example.com/news.do/?language=nl&country=NL

如果我做以下事情,我总是得到news.jsp而不是.do

If I do things like the following I always get news.jsp and not .do

out .PRINT(request.getServletPath());
out.print(request.getRequestURI());
out.print(request.getRequest());
out.print(request.getContextPath());

推荐答案

给定URL = http:/ localhost:8080 / sample / url.jsp?id1 = something& id2 = something& id3 = something

Given URL = http:/localhost:8080/sample/url.jsp?id1=something&id2=something&id3=something

request.getQueryString();

它返回id1 =某事& id2 =某事& id3 =某事

it returns id1=something&id2=something&id3=something

请参阅此

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

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