日期:2014-05-17  浏览次数:20803 次

小弟初学jsp 求大虾们帮忙啊

<% ----这行报错
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
upload.setHeaderEncoding("gb2312");
List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext()) {
FileItem item = (FileItem) iter.next();
if (item.isFormField()) {
String name = item.getFieldName();
String value = new String((item.getString("iso8859-1"))
.getBytes("iso8859-1"), "gb2312");
if ("perID".equals(name)) {
voteTopic.setPerId(Long.parseLong(value));
} else if ("deptID".equals(name)) {
voteTopic.setDeptId(Long.parseLong(value));
} else if ("voteTitle".equals(name)) {
voteTopic.setTitle(value);
voteTopic.setTitle(EDKeyUtil.getInstance().encode(
voteTopic.getTitle()));

} else if ("voteNum".equals(name)) {
voteTopic.setNum(Integer.parseInt(value));
} else if ("itemType".equals(name)) {
voteTopic.setItemType(Integer.parseInt(value));
} else if ("voteType".equals(name)) {
voteTopic.setType(Integer.parseInt(value));
}else if ("voters".equals(name)) {
voteTopic.setArea(value);
} else if ("voteItemIds".equals(name)) {
voteTopic.setVoteItemIds(value);
} else if ("textVoteDesc".equals(name)) {
voteTopic.setDiscription(value);
voteTopic.setDiscription(EDKeyUtil.getInstance()
.encode(voteTopic.getDiscription()));
} else if ("startTime".equals(name)) {
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd");
try {
voteTopic.setStarttime(sdf.parse(value));
} catch (ParseException e) {
e.printStackTrace();
}
} else if ("endTime".equals(name)) {
SimpleDateFormat sdf = new SimpleDateFormat(
"yyyy-MM-dd");
try {
voteTopic.setEndtime(sdf.parse(value));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else if ("topicFlag".equals(name)) {
voteTopic.setFlag(("send".equals(value)) ? 1 : 0);
flag = ("send".equals(value)) ? "send" : "save";
} else if ("voteItemNames".equals(name)) {
voteTopic.setVoteItemNames(value);
String[] arrNames = value.split("、");

for (String eachName : arrNames) {
VoteItem vi = new VoteItem();
vi.setItemName(eachName);
vi.setItemName(EDKeyUtil.getInstance().encode(
vi.getItemName()));
vi.setTopic(voteTopic);
voteItemset.add(vi);
}

}

} else {

String fieldName = item.getFieldName();
String fileName = item.getName();
String uploadFile = "";
String subFileName = "";
String newName = "";
if (!"".equals(fileName)) {
subFileName = fileName.substring(fileName
.lastIndexOf("\\") + 1);
String extendStr = subFileName.substring(subFileName
.lastIndexOf(".") + 1);
newName = new Date().getTime() + "." + extendStr;
voteTopic.setUploadfileName(subFileName);
voteTopic.setUploadfileName(EDKeyUtil.getInstance()
.encode(voteTopic.getUploadfileName()));
voteTopic.setUploadfile(fileFolder + newName);
voteTopic.setUploadfile(EDKeyUtil.getInstance().encode(
voteTopic.ge