1 5 package com.opensymphony.webwork.dispatcher.multipart; 6 7 import com.oreilly.servlet.MultipartRequest; 8 9 import javax.servlet.http.HttpServletRequest ; 10 import java.io.File ; 11 import java.io.IOException ; 12 import java.util.Collections ; 13 import java.util.Enumeration ; 14 import java.util.List ; 15 16 17 25 public class CosMultiPartRequest extends MultiPartRequest { 26 28 private MultipartRequest multi; 29 30 32 40 public CosMultiPartRequest(HttpServletRequest servletRequest, String saveDir, int maxSize) throws IOException { 41 String encoding = getEncoding(); 42 43 if (encoding != null) { 44 multi = new MultipartRequest(servletRequest, saveDir, maxSize, encoding); 45 } else { 46 multi = new MultipartRequest(servletRequest, saveDir, maxSize); 47 } 48 } 49 50 52 public Enumeration getFileParameterNames() { 53 return multi.getFileNames(); 54 } 55 56 public String [] getContentType(String fieldName) { 57 return new String []{multi.getContentType(fieldName)}; 58 } 59 60 public File [] getFile(String fieldName) { 61 return new File []{multi.getFile(fieldName)}; 62 } 63 64 public String [] getFileNames(String fieldName) { 65 return new String []{multi.getFile(fieldName).getName()}; 66 } 67 68 public String [] getFilesystemName(String name) { 69 return new String []{multi.getFilesystemName(name)}; 70 } 71 72 public String getParameter(String name) { 73 return multi.getParameter(name); 74 } 75 76 public Enumeration getParameterNames() { 77 return multi.getParameterNames(); 78 } 79 80 public String [] getParameterValues(String name) { 81 return multi.getParameterValues(name); 82 } 83 84 public List getErrors() { 85 return Collections.EMPTY_LIST; 86 } 87 88 95 private static String getEncoding() { 96 return "utf-8"; 97 98 100 110 } 111 } 112 | Popular Tags |