我正在尝试使用 apache commons fileupload 解析 HTML 表单,所有文本框值都正常传递,提交的文件也是如此,但我无法解析列表框值。解析的代码是
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
ServletFileUpload upload = new ServletFileUpload();
try {
@SuppressWarnings("unchecked")
List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(req);
for (int i=0; i<items.size(); i++){
System.out.println(items.get(i).getName());
System.out.println(items.get(i).getFieldName());
System.out.println(items.get(i).getString());
}
} catch (FileUploadException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
}
任何指南都会非常有用。