小弟在做将excal表导入数据库的项目 遇到个小问题,就是不能得到绝对路径,请各位大牛指教!以下是代码片段
form action="servlet/tomysqlservlet2" method="post">
选择文件1:
<input type="file" name="excel" />
<input type="submit" value="导入" />
</form>
上面是jsp。public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
into in=new into();
excel ex=new excel();
String path=request.getParameter("excel");
System.out.println(path);
File file=new File(path);
List ls=ex.addCustomerAssign(file);
Iterator iter=ls.iterator();
while(iter.hasNext())
{
mynews ms=(mynews)iter.next();
if(in.insertexcel(ms))
System.out.println("成功");
else
System.out.println("失败");
}
}
这里是servlet,我想在System.out.println(path);处测试下得到的path,但是每次打印出来的都是“ddd。xls”,而我想得到的是他的绝对路径d:\ddd。xls 请问如何解决!
form action="servlet/tomysqlservlet2" method="post">
选择文件1:
<input type="file" name="excel" />
<input type="submit" value="导入" />
</form>
上面是jsp。public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
into in=new into();
excel ex=new excel();
String path=request.getParameter("excel");
System.out.println(path);
File file=new File(path);
List ls=ex.addCustomerAssign(file);
Iterator iter=ls.iterator();
while(iter.hasNext())
{
mynews ms=(mynews)iter.next();
if(in.insertexcel(ms))
System.out.println("成功");
else
System.out.println("失败");
}
}
这里是servlet,我想在System.out.println(path);处测试下得到的path,但是每次打印出来的都是“ddd。xls”,而我想得到的是他的绝对路径d:\ddd。xls 请问如何解决!
解决方案 »
- 问一个关于TreeSet的问题
- Map不同步的问题,(我刚才发的贴怎么变成了404,fuck)
- 字符串排序有几种方法
- 我快疯了,帮我看看什么问题.谢谢啊
- ajaxtags框架报错-----java.lang.noclassdefounderror
- >琴声刺骨<--当我埋头于JSP,EJB,STRUTS的时候,她在...分多无用,散!进来有分!
- Jboss与Tomcat/Jetty整合,是在同一个进程中运行吗?
- 急问:如何用java调用windows的本地函数
- 怎么从阿帕奇poi官网下载测试用例啊
- 异常求助,A child container failed during start
- 正则问题
- ant
得到的是个字符串. 你应该得到文件File对象.然后获得路径.
得到的应该是文件在客户端的路径,服务器自然无法得到咯
String path="d:\\ddd.xls"; 把path写死。