请教:在JSP中读取文件的问题 这是空指针错误。你这样输出到页面看文件路径对不对<%=application.getRealPath("\exam\1.xml")%> 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\csdn \file \file.jsp \a.txt <% String path = (request.getRealPath("")); //File f = new File("/csdn/file/a.txt"); File f = new File(path + "/file/a.txt"); if (f.exists()) { out.print("hello world"); } else { out.print("the path no files"); } %> 很遗憾以上方法都试了一个不好用<%=application.getRealPath("\exam\1.xml")%>为nullString path = (request.getRealPath(""));也为null曾怀疑application是不是不好用了可是rgf File reportFile = new File(application.getRealPath("/exam/1.xml")); 试试monkeyhjl(爬上墙头等红杏) ( )的。你的path肯定有问题,要么\\exam\\1.xml,要么如楼上所说。当然不排除其他错误 ext是如何跟后台java交互的。 超级连接传值的问题 十万火急啊! 谁知道“深圳市国电信息技术股份有限公司”的情况 如何实现弹出窗口???????? java程序员如何学习电子商务,构建电子商务模式的网站 求Tomcat+JDK+DB2连接池的配置! Tomcat4.1应用程序部署问题!~小弟弟很郁闷~各位大虾帮忙!~~~ 如何配置jdk(急!!!在线等!!!) 修改xml节点问题 multipart/form-data 是什么意思 在servlet上实例化 一个类在,页面上想引用其数据,应该怎么写,代码如下
\file
\file.jsp
\a.txt
<%
String path = (request.getRealPath(""));
//File f = new File("/csdn/file/a.txt");
File f = new File(path + "/file/a.txt");
if (f.exists()) {
out.print("hello world");
} else {
out.print("the path no files");
}
%>
以上方法都试了
一个不好用
<%=application.getRealPath("\exam\1.xml")%>
为null
String path = (request.getRealPath(""));
也为null
曾怀疑application是不是不好用了
可是rgf
你的path肯定有问题,要么\\exam\\1.xml,要么如楼上所说。当然不排除其他错误