未定义405(不允许的方法)Angularjs + AJAX [英] undefined 405 (Method Not Allowed) Angularjs + ajax

查看:210
本文介绍了未定义405(不允许的方法)Angularjs + AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在想我的手放在Angularjs +休息,并尝试获取数据时,我得到的错误 - 未定义405(不允许的方法)

i've been trying my hand on Angularjs + rest and when trying to get the data , i am getting the error - undefined 405 (Method Not Allowed)

main.js -

main.js --

   url:'http://abc.org/angularDemo/rest/demo/studentJson',
                          type:'GET'}).success(function (sampleData) {
                              alert("here ... "+sampleData);
                        $scope.setPagingData(sampleData,page,pageSize);
                    }).error(function () {
                        alert("Error getting users.");
                    });


@Path("/demo")
@XmlRootElement
public class AngularDataObj {

    @GET
    @Path("/studentJson")
    @Produces(MediaType.APPLICATION_JSON)
    public List<StudentObj> studentJson(){

        List<StudentObj> list = new ArrayList<StudentObj>();
        StudentObj obj = new StudentObj();
        //Map<String,StudentObj> map = new HashMap<String,StudentObj>();
        for(int i=0 ; i< 50; i++){
            obj.setName("name"+i);
            obj.setAge(20+i);
            obj.setId(i);
            obj.setLocation("location"+i);
            list.add(obj);
            //map.put(""+i, obj);
        }

        return list;

    }
}

我能够看到的JSON对象时我直接访问这个网址 - 的http:// ABC .ORG / angularDemo /休息/演示/ studentJson

推荐答案

改变你的web.config,删除以下注册表项:

Change your web.config, removing the following keys:

<system.webServer>
    <modules>
        <remove name="WebDAVModule" />
    </modules>
    <handlers>
        <remove name="WebDAV" />
    </handlers>
</system.webServer>

来源: <一href="http://www.askamoeba.com/Answer/196/Http-405-Method-Not-Allowed-error-Web-API-Controller-PUT-Request-AngularJs" rel="nofollow">http://www.askamoeba.com/Answer/196/Http-405-Method-Not-Allowed-error-Web-API-Controller-PUT-Request-AngularJs

问候。

这篇关于未定义405(不允许的方法)Angularjs + AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆