我怎么能找到如果一些图像文件存在于webapp目录或不动态



假设我试图找到一些图像文件存在于web应用程序中,但不知道真正的路径,即我有绝对路径,我如何得到该路径?

javax.servlet.servletcontext.getrealpath (" "),

不适合我…

谢谢

尝试像这样使用getRealPath

ServletContext context = session.getServletContext();
String realContextPath = context.getRealPath(request.getContextPath());
同样,weblogic也有一个名为 的属性
<show-archived-real-path-enabled>true</show-archived-real-path-enabled>

需要设置为true才能使getrealpath工作,http://rocksolutions.wordpress.com/2010/07/15/servletcontext-getrealpath-is-cause-problems-on-weblogic/

最新更新