解决从tomcat移植到weblogic的两个问题

解决从tomcat移植到weblogic的两个问题 1. 用XmlHttp获取xml,responseXml为空。 解决方法: 在web.xml中加入 xml text/xml xsl text/xml 2. 用SmartUpload下载文件时出错 出错信息: java.io.IOException: 文件名、目录名或卷标语法不正确。 at java.io.WinNTFileSystem.canonicalize0(Native Method) at java.io.Win32FileSystem.canonicalize(Win32FileSystem.java:395) at java.io.File.getCanonicalPath(File.java:531) at weblogic.servlet.internal.WebAppServletContext.getRealPath (WebAppServletContext.java:666) at com.jspsmart.upload.SmartUpload.isVirtual(SmartUpload.java:1180) Truncated. see log file for complete stacktrace 解决方法:自己写了一个Servlet来下载文件,代码如下: 1public class DownLoad extends HttpServlet 2{ 3 private static final long serialVersionUID = -84138329260803824L; 4 public void init() throws ServletException 5 { 6 } 7 8 public void doGet(HttpServletRequest request, HttpServletResponse response) 9 throws ServletException, IOException 10 { 11 OutputStream os = null; 12 FileInputStream fis = null; 13 try 14 { 15 String fileName = request.getParameter("filename"); //要下载的文件,包括路径 16 String downFileName = fileName.substring(fileName.lastIndexOf("\\") + 1); //去掉路径 17 18 os = response.getOutputStream(); 19 File f = new File(fileName); 20 21 response.setHeader("Content-type:", "application/octet-stream"); 22 response.setHeader("Accept-Ranges:", "bytes"); 23 response.setHeader("Accept-Length:", Long.toString(f.length())); 24 response.setHeader("Content-Disposition", "attachment; filename=" + downFileName); 25 26 fis = new FileInputStream(f); 27 byte[] b = new byte[1024]; 28 int i = 0; 29 while((i = fis.read(b)) > 0) 30 os.write(b, 0 ,i); 31 } 32 catch (Exception e) 33 { 34 e.printStackTrace(); 35 } 36 finally 37 { 38 fis.close(); 39 os.flush(); 40 os.close(); 41 } 42 } 43 44 public void doPost(HttpServletRequest request, HttpServletResponse response) 45 throws ServletException, IOException 46 { 47 doGet(request,response); 48 } 49}

你可能感兴趣的:(java,tomcat,xml,weblogic,OS)