首页 > 代码库 > struts2笔记

struts2笔记

1.获取项目根路径:

HttpServletRequest request = ServletActionContext.getRequest();//获取物理根路径String basePath = request.getSession().getServletContext().getRealPath("/");//获取网络根路径String baseUrl = request.getScheme()+":"+request.getServerName()+":"+request.getServerPort()+request.getContextPath();//获取web相对路径String rootPath = request.getContextPath();

 

struts2笔记