@RequestParam 和@RequestBody的使用方式
来源:互联网 发布:顾家北和慎小嶷 知乎 编辑:程序博客网 时间:2024/06/05 18:33
@RequestParam annotated parameters get linked to specific Servlet request parameters. Parameter values are converted to the declared method argument type. This annotation indicates that a method parameter should be bound to a web request parameter.
For example Angular request for Spring RequestParam(s) would look like that:
$http.post('http://localhost:7777/scan/l/register', {params: {"username": $scope.username, "password": $scope.password, "auth": true}}). success(function (data, status, headers, config) { ... })@RequestMapping(method = RequestMethod.POST, produces = "application/json", value = "/register")public Map<String, String> register(Model uiModel, @RequestParam String username, @RequestParam String password, boolean auth, HttpServletRequest httpServletRequest) {...
@RequestBody annotated parameters get linked to the HTTP request body. Parameter values are converted to the declared method argument type using HttpMessageConverters. This annotation indicates a method parameter should be bound to the body of the web request.
For example Angular request for Spring RequestBody would look like that:
$scope.user = { username: "foo", auth: true, password: "bar" }; $http.post('http://localhost:7777/scan/l/register', $scope.user). success(function (data, status, headers, config) { ... })@RequestMapping(method = RequestMethod.POST, produces = "application/json", value = "/register")public Map<String, String> register(Model uiModel, @RequestBody User user, HttpServletRequest httpServletRequest) {...
Hope this helps.
0 0
- @RequestParam 和@RequestBody的使用方式
- @RequestParam和@RequestBody的区别-------springMVC
- springMVC中 @RequestParam和@RequestBody的区别
- @RequestBody和@RequestParam区别
- @RequestParam 和@RequestBody详解
- @RequestBody和@RequestParam区别
- requestparam和requestbody区别
- @RequestBody和@RequestParam区别
- @RequestBody和@RequestParam区别
- @RequestBody和@RequestParam区别
- @RequestParam和@RequestBody
- SpringMVC @requestBody和requestParam
- spring @RequestBody和@RequestParam区别
- @PathVariable、@RequestParam、@RequestBody的区别
- Spring MVC 在@RequestParam和@RequestBody中使用Java 8时间LocalDateTime
- @RequestParam @RequestBody @PathVariable
- @RequestParam @RequestBody @PathVariable
- @RequestBody与@RequestParam
- ReactiveCocoa框架菜鸟入门——信号(Signal)详解 第五课:适合给新手看的RAC用法总结
- (p143)11.1-4大数组直接寻址
- JavaSE程序分析002 try-catch-finally与return的小事情
- Leetcode之super ugly number
- viewpageindicator +fragment 在网络访问中与volley框架 null问题
- @RequestParam 和@RequestBody的使用方式
- 三维旋转矩阵推导
- 省选算法汇集(持续更新)最后更新2016.2.29
- 软件测试面试 (一) 如何测试一个杯子
- hibernate-validator的使用说明
- BZOJ1195 HNOI2006 最短母串
- 【Python学习笔记】一个很酷的尾递归优化
- mybatis代码自动生成
- 2337: [HNOI2011]XOR和路径 高斯消元解期望方程 概率与期望DP