小编Vla*_*sky的帖子

Ajax json POST和Spring MVC Controller

我有像这样的ajax json POST方法

$.ajax({
    type: 'POST',
    url: "localhost:8080/webeditor/spring/json/", 
    data: JSON.stringify(contents),
    dataType: "json"
});
Run Code Online (Sandbox Code Playgroud)

控制器处理发布请求

JSONPObject json;
BindingResult result = new BeanPropertyBindingResult( json , "MyPresentation" );
@RequestMapping(value="json/", method = RequestMethod.POST)
public void savePresentationInJSON(Presentations presentation,BindingResult result) {
        //do some action

}
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个错误

XMLHttpRequest无法加载localhost:8080/webeditor/spring/json /.仅支持HTTP的跨源请求.

我不确定如何纠正上述错误.

java ajax spring spring-mvc

4
推荐指数
1
解决办法
4万
查看次数

标签 统计

ajax ×1

java ×1

spring ×1

spring-mvc ×1