首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web开发 >

java URL 报错:java.io.FileNotFoundException: Response: '404: Not Found' for url:

2012-02-02 
javaURL报错:java.io.FileNotFoundException: Response: 404: Not Found for url: - Web 开发 / 其他我

java URL 报错:java.io.FileNotFoundException: Response: '404: Not Found' for url: - Web 开发 / 其他
我写了一个去其他地址下载文档的jap,本机上用没问题,但到了linux 上就报
java.io.FileNotFoundException: Response: '404: Not Found' for url: 'http://10.192.27.22:7001/webapp/浙江分公司/日报测试.xls'
  at weblogic.net.http.HttpURLConnection.getInputStream(HttpURLConnection.java:472)
  at weblogic.net.http.SOAPHttpURLConnection.getInputStream(SOAPHttpURLConnection.java:36)
  at jsp_servlet._releakage.__unknown._jspService(__unknown.java:131)
  at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
  at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
  at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
  at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:283)
求各位大哥指点迷津啊,我的代码是:
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.net.*" %>
<%@ page import="sun.net.ftp.FtpClient" %>
<html>
<head>

</head>
<body>
<%request.setCharacterEncoding("UTF8");
response.reset();
String ursename = request.getParameter("unitname");
String filename = request.getParameter("filename");
if(ursename!=null){
ursename = new String(ursename.getBytes("ISO-8859-1"),"utf-8");
}
if(filename!=null){
filename = new String(filename.getBytes("ISO-8859-1"),"utf-8");
}
//System.out.println(ursename+"\\\\\"+filename);
response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("content-disposition", "attachment;filename=\""
+ java.net.URLEncoder.encode(filename, "UTF-8") + "\"");
//FtpClient ftpclient = new FtpClient("10.190.50.16",90);
%>

<%
InputStream in = null;
OutputStream outp = null;
//String url = "/"+ursename+"/"+filename;

try {
//ftpclient.login("0","CFT^7ujm");
//ftpclient.binary();
//in = new URL( " ftp://10.190.50.16:90/北京分公叄1?7/防渗漏系统日统计快报_北京分公司_2011-12-09.xls").openConnection().getInputStream();
//in =ftpclient.get(url);
String url2 = "http://10.192.27.22:7001/webapp/浙江分公司/日报测试.xls";
URL url = new URL(url2);  
URLConnection urlcon=url.openConnection();
in = urlcon.getInputStream();
outp = response.getOutputStream();
byte[] b = new byte[1024];
int i = 0;

while ((i = in.read(b)) > 0) {
outp.write(b, 0, i);
}
outp.flush();
} catch (Exception e) {
System.out.println("Error!");
e.printStackTrace();

} finally {
if (in != null) {
try {
in.close();
in = null;
} catch (IOException e) {
e.printStackTrace();
}
}
//ftpclient.sendServer("QUIT\r\n");
}
if (outp != null) {
try {
outp.close();
outp = null;
} catch (IOException e) {
e.printStackTrace();
}
}

%>

<%out.clear();
out = pageContext.pushBody(); 
%>
</body>
</html>

[解决办法]
404就是没这页面
路径不对吧
[解决办法]
中文改成英文试试


[解决办法]

探讨

英文,我没试过,但我在IE中直接打路径,是可以打开这个url的,我以后要做的也全是中文路径,所有英文是不行的

[解决办法]
String url2 = "http://10.192.27.22:7001/webapp/浙江分公司/日报测试.xls";
url2 = java.net.URLEncoder.encode(url2, "UTF-8");

转码试下

热点排行