在进行图片上传中 Action的添加
private BookService bs;
private Book book;
private fiel file1;
private String file1FileName;(错误原因:自己没有按照前面的变量名来取,而是自己命名了一个file2
导致出错,报空指针异常。固定写法file1FileName)
生成get/set方法
public String insert(){
String newFIle = UUID.randowUUID.toString() + file1FileName.substring(file1FileName.lastIndexOf("."));
book.setOldName(file1FileName);
book.setNewName(newFile);
bs.insert(book);
在页面中写成
<input name="file1" type="file" ...>
}