鍍金池/ 問答/Java/ springmvc 接收list問題

springmvc 接收list問題

    @RequestMapping("poster/add")
    @ResponseBody
    public ResultVo addPoster(Long categoryKey, Long typeId, String typeValue, @RequestBody List<ActivityPosterImageVo> imgList, HttpServletRequest request,
                              HttpServletResponse response){
     dosomething()
    }

前臺傳輸數(shù)據(jù)

{categoryKey: 1, typeId: "1", typeValue: "學習", imgList: [{imgId: "87",…}]}

為什么顯示400 (Bad Request)

回答
編輯回答
凹凸曼

400:語法格式有誤,服務器無法理解此請求
前臺請求怎么寫的?

2018年1月26日 23:38
編輯回答
祉小皓

可能就是 ccfish 說的問題

建議你這邊下載一個postman,然后通過postman發(fā)送請求,像此類問題,最好把請求的方式和數(shù)據(jù)截一個圖

2018年6月8日 15:38
編輯回答
六扇門
    @RequestMapping("poster/add")
    @ResponseBody
    public ResultVo addPoster(@RequestBody PosterRequest req, HttpServletRequest request,
                              HttpServletResponse response){
     dosomething()
    }
    
    class PosterRequest {
    Long categoryKey; Long typeId; String typeValue; List<ActivityPosterImageVo> imgList
    /// getter setter methods
    }
2017年7月18日 17:45