Spring MVC 4: “application/json” Content Type is not being set correctly

前端 未结 6 1677
旧巷少年郎
旧巷少年郎 2020-11-30 00:41

I have a controller mapped with the following annotation:

@RequestMapping(value = \"/json\", method = RequestMethod.GET, produces = \"application/json\")
@Re         


        
6条回答
  •  隐瞒了意图╮
    2020-11-30 01:05

    Use jackson library and @ResponseBody annotation on return type for the Controller.

    This works if you wish to return POJOs represented as JSon. If you woud like to return String and not POJOs as JSon please refer to Sotirious answer.

提交回复
热议问题