@RequestMapping(value = "/wxtest", method = RequestMethod.GET)
@SJson
@Filters({@By(type=CrossOriginFilter.class)})
public Object wxtest(@RequestParam String param) {
try {
System.out.print("param="+param);
return Result.success("ok");
} catch (Exception e) {
return Result.error("fail");
}
}
本地访问html 地址为:file:///D:/html/dist/html/leaseindex.html 里面调了这个方法
$(function () {
$.get('http://qqz0fa9ea23.ngrok.wendal.cn/open/api/token/wxtest?param=xxxx',function(data){
//内网穿透地址
console.log(data)
console.log("sssssssssssssssssssssss");
})
$.get("http://127.0.0.1:8080/open/api/token/wxtest?param=xxxx",function(data){
console.log(data)
console.log("sssssssssssssssssssssss");
})
})
浏览器报错 :Failed to load http://127.0.0.1:8080/open/api/token/wxtest?param=xxxx: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.
leaseindex.html:1 Failed to load http://qqz0fa9ea23.ngrok.wendal.cn/open/api/token/wxtest?param=xxxx: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access