spring mvc返回jsonp內容

魔豆發表於2017-03-13

程式碼如下:

   import com.alibaba.fastjson.JSONPObject; 

  @RequestMapping(value = "/method1") @ResponseBody public JSONPObject method1(Req req,String callback) { JSONPObject returnJsonp = new JSONPObject(callback); try { Object obj = "hello"; returnJsonp.addParameter(obj); } catch (Exception e) { } return returnJsonp; }

 

相關文章