标签:端口号 ati return sch 端口 获取 protoc path explain
import javax.servlet.http.HttpServletRequest; public class httpurl { /** * 获取url请求前缀,获取当前项目地址 * @explain http://localhost:8080/test * @param request request对象 * @return */ public static String getRequestPrefix (HttpServletRequest request) { // 网络协议 String networkProtocol = request.getScheme(); // 网络ip String ip = request.getServerName(); // 端口号 int port = request.getServerPort(); // 项目发布名称 String webApp = request.getContextPath(); String urlPrefix = networkProtocol + "://" + ip + ":" + port + webApp; return urlPrefix; } }
标签:端口号 ati return sch 端口 获取 protoc path explain
原文地址:https://www.cnblogs.com/xymaxbf/p/12057055.html