实例如下:

ServletRequestAttributes aRequestAttributes=(ServletRequestAttributes)RequestContextHolder.getRequestAttributes(); HttpServletRequest request =aRequestAttributes==null?null:aRequestAttributes.getRequest(); String webpath=request.getServletContext().getRealPath("/");

以上这篇Java 获取Web项目相对webapp地址的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持亿速云。