浏览 2677 次
锁定老帖子 主题:Tomcat 路径问题之web 头像
该帖已经被评为新手帖
|
|
---|---|
作者 | 正文 |
发表时间:2010-02-07
最后修改:2010-02-24
System.out.println(request.getRealPath("")); System.out.println(request.getContextPath()); System.out.println(getServlet().getServletContext().getRealPath("/")); 依次输出: d:\apache-tomcat-5.5.26\webapps\project /project d:\apache-tomcat-5.5.26\webapps\project\ 在jsp页面中直接使用 ${pageContext.request.contextPath}就可以找到 C:\apache-tomcat-5.5.26\webapps\project\ 只用在Tomcat的这个目录下建立你想要的文件夹就可以了 也可以直接在工程下建立目录 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2010-02-09
servlet spe 写道
In situations where the servlet container cannot determine a valid file path for
these methods, such as when the Web application is executed from an archive, on a remote file system not accessible locally, or in a database, these methods must return null. 所以getRealPath()最好不要用,像打成war包时会返回null |
|
返回顶楼 | |
发表时间:2010-02-09
flynofry 写道
servlet spe 写道
In situations where the servlet container cannot determine a valid file path for
these methods, such as when the Web application is executed from an archive, on a remote file system not accessible locally, or in a database, these methods must return null. 所以getRealPath()最好不要用,像打成war包时会返回null 打包成WAR最后运行的时候不也要解压成文件夹的形式吗?有什么错? |
|
返回顶楼 | |
发表时间:2010-02-09
超级潜水艇 写道 flynofry 写道
servlet spe 写道
In situations where the servlet container cannot determine a valid file path for
these methods, such as when the Web application is executed from an archive, on a remote file system not accessible locally, or in a database, these methods must return null. 所以getRealPath()最好不要用,像打成war包时会返回null 打包成WAR最后运行的时候不也要解压成文件夹的形式吗?有什么错? 好像有的容器不会自动解压WAR包的…… |
|
返回顶楼 | |