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就是没这页面
路径不对吧
[解决办法]
中文改成英文试试
[解决办法]