<form id="add" method="post" enctype="multipart/form-data"> <label>书名:</label> <input class="easyui-validatebox" type="text" name="bookName" id = "bookName" required="true"> <label>作者:</label> <input class="easyui-validatebox" type="text" name="authorName" id="authorName" required="true"> <lebel>封面:</lebel> <input type="file" name="file" id="file" /> <div class="submit"> <input type ="button" value="提交" id = "addSubmit"> </div> </form>
我们可以采用formdata进行表单数据的提交:
通过formData获取form的Id进而获取form表单中的值,
那么如何获取formdata中的参数值呢
可以通过 var bookName = formData.getname("bookName"),查看值, name为要查看的name名
这样我们就能够获取到file了,那么问题来了,如何在后台接收呢
方法中参数MutipartFile file就行
可以通过打印file.getOriginalFilename()获取到前台传来的参数