获取http请求地址
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
String path = request.getContextPath();
String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
本文介绍了一种通过Java Servlet API获取当前HTTP请求完整URL的方法。利用`HttpServletRequest`接口中的`getContextPath()`, `getScheme()`, `getServerName()`, `getServerPort()`等方法组合起来得到请求的基本路径。
1万+

被折叠的 条评论
为什么被折叠?



