servlet为什么不执行?
Jsp页面:
<form id="photoForm" action="PhotoServlet?method=0" enctype="multipart/form-data" method="post" onsubmit="return subPhotoFrom()">
<table>
<tr><td colspan="2" align="center">相片上传</td></tr>
<tr>
<td>上传地址:</td>
<td><input type="file" name="imageAddress" id="imageAddress"></td>
</tr>
<tr>
<td>相片描叙:</td>
<td><input type="text" maxlength="100" name="photoDescription" id="photoDescription"/></td>
</tr>
<tr>
<td colspan="2">注意:图片格式只能为:"JPG","jpg","GIF","gif","BMP","bmp"</td>
</tr>
<tr>
<td align="right"><input type="submit" value="添加"/></td>
<td align="center"><input type="button" value="取消" onClick="hideForm('photoAdd')"/></td>
</tr>
</table>
</form>
Servlet:
int method = Integer.valueOf(request.getParameter("method"));
PhotoDao photoDao = new PhotoDao();
PhotoForm photoForm = new PhotoForm();
System.out.println(method);
//上传相片
if(method==0)
{
try {
SmartUpload upload = new SmartUpload();
upload.initialize(getServletConfig(), request, response);
upload.setMaxFileSize(1024 * 1024);
upload.setAllowedFilesList("jpg,bmp,gif,png,JPG,GIF,BMP");
upload.upload();
upload.save(request.getContextPath()+"/photo");
System.out.println(request.getContextPath()+"/photo"+upload.getFileNames()[0]);
photoForm.setPhotoAddress(upload.getFileNames()[0]);
photoForm.setPhotoDescription(Chinese.toChinese(request.getParameter("photoDescription")));
} catch (Exception e) {
System.out.println("上传出错!");
e.printStackTrace();
}
}
为什么页面跳转到servlet就没反应了?我的打印语句都没有执行,post提交的,在post里调用的这个get方法,不存在问题的,起初以为是图片上传的问题所以看不到效果,加上了打印语句结果控制台都没显示,post方法里的也没有执行。很显然是servlet没有执行了,为什么啦?救命。。。。