我一直在尝试Angularjs +休息,当我试图获取数据时,我收到错误 - 未定义405(方法不允许)
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/rest/demo/studentJson
答案 0 :(得分:0)
更改您的web.config,删除以下键:
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<remove name="WebDAV" />
</handlers>
</system.webServer>
问候。