requestparam注解用法 requestbody和requestparam区别?
requestbody和requestparam区别?
Requestbody
处理httpentity传递的数据,通常用于处理非内容类型的数据:application/x-www-form-urlencoded格式。
在get请求中,@requestbody不适用,因为没有httpentity。
在post请求中,通过httpentity传递的参数必须在请求头中声明数据类型content type。Spring MVC使用由
handleradapter配置的httpmessage转换器解析httpentity中的数据,然后将其绑定到相应的bean。
Requestparam
用于处理内容类型:content encoded for application/x-www-form-urlencoded。(在HTTP协议中,如果未指定内容类型,则传递的默认参数是application/x-www-form-urlencoded type)
@RequestParam和@RequestBody的区别?
最近,我们还遇到了这个问题,因为表单本身不支持put方法。
解决方案:
1:使用@requestbody而不是@requestparam
2:不要使用表单发送参数
~]@requestmapping(value=“/list”,方法=请求方法.GET)
public String getAll(Model){
Set<GroupSecure> secures=快去拿()
模型.addAttribute(“secures”,secures)
return“group/list”
}
@RequestMapping(value=“/list”,method=请求方法.GET,params=“method=one”)
公共字符串getOneUser(@RequestParam(value=“name”)字符串名,Model Model){
Set<GroupSecure> secures=redisDao.getByName(姓名)模型.addAttribute(“secures”,secures)
return“group/list”
}
requestparam注解用法 spring mvc教程 requestparam注解参数名不一致
版权声明:本文内容由互联网用户自发贡献,本站不承担相关法律责任.如有侵权/违法内容,本站将立刻删除。