spring mvc中同时包含requestparam和requestbody传递参数

@RequestMapping(value="/pushToCidList/link",method=RequestMethod.POST)

public HttpResult pushToCidListLink(

@RequestParam("content") String content,

@RequestParam("title") String title,

@RequestParam("url") String url,

@RequestBody List cids

) {

LinkTemplatePushModel pushModel = new LinkTemplatePushModel();

pushModel.setContent(content);

pushModel.setTitle(title);

pushModel.setUrl(url);

HttpResult result = new HttpResult(true,"");

return result;//appPushService.pushToCidList(cids, pushModel);

 

}

 

 

POSTMAN进行模拟:

使用SpringMVC框架,controller使用参数  @RequestBody  LoginReq req   注解方式模拟http请求

需要请求header添加两个参数

spring mvc中同时包含requestparam和requestbody传递参数_第1张图片

设置  Header参数    Content-Type    application/json

body参数选择

spring mvc中同时包含requestparam和requestbody传递参数_第2张图片

body里面:JSON:["1","2"]

你可能感兴趣的:(spring mvc中同时包含requestparam和requestbody传递参数)