日期:2014-05-17  浏览次数:20636 次

怎样上传文件到java web项目中,而不是tomcat服务器中
RT,怎样上传文件到java web项目中,而不是tomcat服务器中,望大虾们指教,在线等.

------解决方案--------------------
引用:
我项目的目录
C:\workspace\HuLianVer4\webparent\UserPlatform\src\main\webapp\WEB-INF\views\help\upload
用request.getSession().getServletContext().getRealPath("/")得到的却是这个
C:\workspace\.metadata\.plugins\org……


C:\workspace\HuLianVer4\webparent\UserPlatform\src\main\webapp\WEB-INF\views\help\upload
这个明显是你的开发路径

C:\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\UserPlatform\
这个是你用eclipse开发过程中,使用eclipse自带的tomcat发布项目的位置

获取路径的代码没有问题,只是你使用了eclipse来自动部署应用,获取的肯定是eclipse部署的位置,也是真实的项目运行路径,要想获取你自己想要的路径,必须你自己手动部署项目到指定目录,同时在tomcat里手动配置Context,才能达到你想要的效果。