本人小白 今天从网页上传图片的时候碰到一个错误 只在网页显示
HTTP Status 400 -
The request sent by the client was syntactically incorrect.其他什么也没有
jsp页面代码:
form action="/xiangmu/users/uploadfile" method="post"
enctype="multipart/form-data"
input type="file" name="file" /
nput type="submit" value="提交"/
/form
springmvc代码:
@RequestMapping(value="/uploadfile",method=RequestMethod.POST)
public String handleFileUpdate(@RequestParam("file") CommonsMultipartFile file,HttpServletRequest req)throws FileUploadException{
long startTime=System.currentTimeMillis();//获取开始时间
PictureService ps=new PictureService();
Picture pic=new Picture();
if(!file.isEmpty()){
try {
String aa=file.getName();
String ppath="D:/pic/"+aa+".jpg";
File ouputimage=new File(ppath);//新建一个文件
try {
file.getFileItem().write(ouputimage);//将上传的文件写入新建的文件中
} catch (Exception e) {
e.printStackTrace();
}
pic.setPpath(ppath);pic.setCreatedate(new Date());pic.setUuid(1);
ps.addPicture(pic);
} catch (Exception e) {
e.printStackTrace();
}
}
long endTime=System.currentTimeMillis();//获取结束时间
System.out.println("上传文件共使用时间:"+(endTime-startTime));
return "/index.jsp";
}
求帮忙 真的不知道为什么