目次
1.1 Springは、@ RequestParamを使用して単純な配列を解析します
1.2Springは@RequestBodyを使用して単純な配列を解析します
2.1Springは@RequestParamを使用して単純なリストを解析します
2.2Springは@RequestBodyを使用して単純なリストを解析します
2.3Springは@RequestBodyを使用してリストオブジェクトを解析します
3.1Springは@RequestParamを使用してマップを解析します
3.2Springは@RequestBodyを使用してマップを解析します
配列
1.1 Springは、@ RequestParamを使用して単純な配列を解析します
@RequestMapping(value = "/getByIds" ,method = RequestMethod.POST)
public RetDTO getByIds(@RequestParam(value = "ids") Long[] ids){
return RetDTO.getReturnJson(userService.getByIds(ids));
}
郵便配達員のリクエスト方法1
郵便配達員の要求方法2
郵便配達員リクエスト方法3
郵便配達員リクエスト方法4
1.2Springは@RequestBodyを使用して単純な配列を解析します
@RequestMapping(value = "/getByIds" ,method = RequestMethod.POST)
public RetDTO getByIds(@RequestBody Long[] ids){
return RetDTO.getReturnJson(userService.getByIds(ids));
}
郵便配達員のリクエスト方法
2つのリスト
2.1Springは@RequestParamを使用して単純なリストを解析します
@RequestMapping(value = "/getByIds" ,method = RequestMethod.POST)
public RetDTO getByIds(@RequestParam("ids") List<Long> ids){
return RetDTO.getReturnJson(userService.getByIds(ids));
}
郵便配達員のリクエスト方法1
郵便配達員の要求方法2
2.2Springは@RequestBodyを使用して単純なリストを解析します
@RequestMapping(value = "/getByIds" ,method = RequestMethod.POST)
public RetDTO getByIds(@RequestBody List<Long> ids){
return RetDTO.getReturnJson(userService.getByIds(ids));
}
郵便配達員のリクエスト方法
2.3Springは@RequestBodyを使用してリストオブジェクトを解析します
@RequestMapping(value = "/getByIds" ,method = RequestMethod.POST)
public RetDTO getByIds(@RequestBody List<User> userList){
return RetDTO.getReturnJson(userService.getByIds(userList));
}
郵便配達員のリクエスト方法
3つの地図
3.1Springは@RequestParamを使用してマップを 解析します
@RequestMapping(value="/getById", method=RequestMethod.GET)
public RetDTO<User> getById(@RequestParam Map<String, Long> map) {
return RetDTO.getReturnJson(userService.getUserById(map.get("id")));
}
郵便配達員のリクエスト方法
3.2Springは@RequestBodyを使用してマップを 解析します
@RequestMapping(value="/getById", method=RequestMethod.GET)
public RetDTO<User> getById(@RequestBody Map<String, String> map) {
return RetDTO.getReturnJson(userService.getUserById(map));
}
WeChatパブリックアカウント:「NewMonkey One Horse」、WeChatでスキャンします。