NutzCN Logo
问答 Nutz跨域 @Filters加了不行
发布于 2373天前 作者 qq_0fa9ea23 1672 次浏览 复制 上一个帖子 下一个帖子
标签:
@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

1 回复

这是spring mvc,加上nutz的@
'Filters当然不行了

添加回复
请先登陆
回到顶部