1.服务器文件存储路径
String url=this.getRequest().getSession().getServletContext().getRealPath("/");
/home/tomcat/webapps/csdn
2.服务地址
HttpServletRequest quest = this.getRequest();
String pp = quest.getScheme() + "://" + quest.getServerName() + ":" + quest.getServerPort() + quest.getContextPath();
http://192.168.42.111:8080/csdn 对应的前端方法
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
3.springboot中resource目录路径
String path = ClassUtils.getDefaultClassLoader().getResource("").getPath();
4.获取项目根路径
String path = System.getProperty("user.dir")