SpringMvc的傳遞參數方式總結
一、傳遞String類型
controller方法使用String對象做爲參數接收
![](http://static.javashuo.com/static/loading.gif)
controller使用bean做爲參數接收
- ajax提交的參數名須要與TestBean成員對象名對應
![](http://static.javashuo.com/static/loading.gif)
使用HttpServletRequest接收
![](http://static.javashuo.com/static/loading.gif)
二、傳遞數組
使用urlencodeed的形式
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
利用@RequestBody接收
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
使用@RequestParam
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
使用formData
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
三、傳遞複雜對象
使用@requestBody
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
使用form提交
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
四、傳遞文件
使用form提交
![](http://static.javashuo.com/static/loading.gif)
![](http://static.javashuo.com/static/loading.gif)
歡迎關注本站公眾號,獲取更多信息