exp:Controller类里的参数注解

package org.springframework.web.bind.annotation;

1、@RequestParam String identityCardId:URL里的传输参数;

2、(@RequestBody User user):由前端传来的json数据,RequestBody接收的是用POST方式请求的放在body里的json数据,实际上如果body里是json数据,除了上面的用对象接收数据,也可以用简单的String来接收。如( @RequestBody String jsonString )
参考:
https://blog.youkuaiyun.com/justry_deng/article/details/80972817

3、@ModelAttribute:可以用在方法参数或方法体上。用在参数时用于与页面的数据交互,例如:前端有form,

<form:form modelAttribute="book" method="POST" action="show.do"> 
<table> 
.....
</table> 
</form:form>

在后端类里就可以用@ModelAttribute Book book接收。

4、@RequestAttribute Long userId:
可以被用于访问由过滤器或拦截器创建的、预先存在的请求属性
也就是事先存在了例如 request.setAttribute(“userId”,1687);
然后再从这次request中取出这个属性。
(补:还有request.getSession().setAttribute(),关于request、session等更多,见
https://blog.youkuaiyun.com/sinat_15274667/article/details/51585538?utm_source=blogxgwz4)

5、@RequestPart(required = true) MultipartFile userFile
用于文件上传。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值