方式一:String path = RequestContext.class.getResource("/").getFile(); 转载于:https://www.cnblogs.com/LLLONG/p/3345252.html