后端controller接收前端参数的方法

后端controller接收前端参数的方法

1. 使用对象接收的情况

  • Brand类
/**
 * 品牌
 */
@Data
@TableName("tb_brand")
public class Brand {
    
    
    @TableId(type = IdType.AUTO)
    private Long id;
    private String name;
    private String image;
    private String letter;
    private Date createTime;
    private Date updateTime;
}

1.1接收页面普通参数

Brand brand: 用于接收页面的普通参数,

例如:name=xxx&letter=C&image=xxx

1.2接收页面的json参数

@RequestBody Brand brand: 用于接收页面的json参数,
例如:{name:“xxx”,letter:“C”,image:“xxx”}

2.接收页面的同名参数

2.1页面上有两种情况传递的同名参数

 *     1)复选框提交的格式 例如   ids=1&ids=2&ids=3....
 *     2)使用逗号拼接格式 例如   ids=1,2,3....

2.2后台接收同名参数的三种方法

 *       1)字符串     String ids    内容:1,2,3....
 *       2) 数组    Long[] ids     内容:[1,2,3]
 *       3)List集合  List<Long> ids  内容:[1,2,3]  注意:List集合必须添加@RequestParam注解

Memorial Day is 522 days
I miss you
xiaokeai

猜你喜欢

转载自blog.csdn.net/weixin_42914989/article/details/114376902