【发布时间】:2014-07-01 04:58:38
【问题描述】:
我正在尝试使用Servlet 中的以下代码创建一个文件:
File outfile= new File(servletContext.getRealPath("/Output/output.xml"));
OutputStream os = new FileOutputStream(outfile);
来自 J2EE 应用程序 (CallMain),文件在部署的临时路径中创建
.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\CallMain\Output
实际上我希望在当前项目文件夹中创建文件:WebContent.
【问题讨论】:
-
试试这个
File file = new File(getServletContext().getRealPath("/Output/output.xml")); -
谢谢,但结果相同!
-
你有webapp下创建的输出文件夹吗?
-
是的网页内容/输出。
-
嘿试试这样 getServletContext().getRealPath("/")+"Output/output.xml";
标签: eclipse jakarta-ee