Import the javax.servlet.http.HttpServletRequest; public class the HTTPUrl { / ** * prefix acquisition request url, acquires the current address project * @explain HTTP: // localhost : 8080 / Test * @param Request Object Request * @return * / public static String getRequestPrefix (the HttpServletRequest Request) { // network protocol String networkProtocol = request.getScheme (); // network IP String = IP to request.getServerName (); // port number int port = request.getServerPort(); // 项目发布名称 String webApp = request.getContextPath(); String urlPrefix = networkProtocol + "://" + ip + ":" + port + webApp; return urlPrefix; } }
Get the current project addresses
Guess you like
Origin www.cnblogs.com/xymaxbf/p/12057055.html
Recommended
Ranking