How to use @RequestBody with a JSONP request?

左心房为你撑大大i 提交于 2019-12-04 15:37:30

JSONP means that jQuery will create a <script> element with src pointing to your controller URL.

As you can see, this approach doesn't allow you to pass any data in request body, all data should be passed in URL as query parameters. data : { abc : '123' } means that abc=123 is added to the URL.

At controller side you need to use either @RequestParam (to bind inidividual parameters) or @ModelAttribute (to bind multiple parameters into an object):

public ReturnObject getBlahBlah (@RequestParam("abc") int abc) throws Exception { ... }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!