本文介绍了为什么这不起作用 - jsonp和REST Easy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! JS代码<html><head> <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> <script> $.getJSON("http://localhost:8080/gbsshop/rest/auth/test/xyz?callback=?", function (data) { alert("52"); }); </script></head></html> REST简易方法@GET @POST @Path("/test/{param}") @Produces({MediaType.APPLICATION_JSON }) public String returnMessage(@PathParam("param") String msg) { System.out.println("~~~~~~~~~~~~~"+msg+"~~~~~~~~~~~~"); return "HEllo "+msg; }我看到服务器接到电话但浏览器失败了Uncaught SyntaxError:Unexpected IdentifierI see that the server gets the call but the browser fails with "Uncaught SyntaxError: Unexpected Identifier"任何帮助表示赞赏。感谢您的时间。Any help is appreciated. Thanks for the time.推荐答案 Resteasy 声称支持JSONP 开箱即用的3.x版本:Resteasy claims to support JSONP out of the box in 3.x version: GET / resources / stuff?callback = processStuffResponse将产生响应:GET /resources/stuff?callback=processStuffResponse will produce this response: processStuffResponse()这支持jQuery的默认行为。processStuffResponse() This supports the default behavior of jQuery.您可以通过设置 callbackQueryParameter属性来更改回调参数的名称。You can change the name of the callback parameter by setting the callbackQueryParameter property.然而,由于 RESTEASY-1168:Jackson2JsonpInterceptor不呈现结束括号所以 foo ({foo:bar} 渲染而不是 foo({foo:bar})导致未捕获的SyntaxError:意外的标识符错误And that causes "Uncaught SyntaxError: Unexpected Identifier" error我已经明确了 pull-request 带有修复,希望它应该进入下一个版本3.0.12I have submimtted a pull-request with a fix and hopefully it should get into next release 3.0.12我知道这个qustion很老了,但是当你搜索resteasy jsonp问题时它显示在Google的第一页上,所以我决定更新它I know that this qustion is pretty old, but it is shown on the first page of Google when you search for resteasy jsonp problems, so I decided to update it 这篇关于为什么这不起作用 - jsonp和REST Easy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-27 09:05