获取项目地址

1.String pathurl = request.getServletContext().getRealPath("/");

获取到项目的绝对地址,例如: d:/a/a/aaa
2.String weburl = request.getScheme() + "://" + request.getServerName()+ ":" + request.getServerPort() + request.getContextPath();

获取项目的ip地址,例如: http://IP:端口号/项目名  http://172.0.0.1:8080/aaa

猜你喜欢

转载自www.cnblogs.com/Somuns/p/9182140.html