2014-11-23 3 views
0

AngularJS에 문제가있어 POST 요청을했습니다. 내 JSON 잘 만들지 만 내 REST 서비스에 게시 할 때 나는에 문제가있어 내 GET 요청이 잘 작동하기 때문에 왜, 난 정말 모르는왜 AngularJs로 POST 요청을 할 수 없습니까?

WARNING: No operation matching request path "/ws/resources/Users/Add" is found, Relative Path: /Add, HTTP Method: POST, ContentType: application/json, Accept: application/json,text/plain,*/*,. Please enable FINE/TRACE log level for more details. 

합니다. 내가 JSON을하고 POST 요청을 어떻게

$http.get('resources/Users/All').success(function(data) { 
     $scope.clients = data; 
    }); 

이것은 :

@Path("/Users") 
@Consumes(MediaType.APPLICATION_JSON) 
@Produces(MediaType.APPLICATION_JSON) 
public class UserRESTResource { 

    @GET 
    @Path("/All") 
    public List<UserDto> getClients() { 
     //that works fine 
    } 

    @POST 
    @Path("/Add/{user}") 
    public void add(@PathParam("user") UserDto userDto) { 
     //to sth 
    } 
} 

이 내가 작동 GET 요청을하는 방법입니다

여기

나머지 서비스 코드의 샘플입니다 :

$scope.Add = function() { 
     $http({ 
       method: "POST", 
       url: "resources/Users/Add", 
       data: { 
        "user" : { 
         "firstName" : $scope.firstNameA, 
         "lastName" : $scope.lastNameA, 
        } 
       }, 
       headers: {'Content-Type':'application/json'} 
      }); 
    } 

UserDto :

@XmlRootElement(name = "user") 
@XmlAccessorType(XmlAccessType.FIELD) 
public class UserDto { 
public long id; 
public String firstName; 
public String lastName; 
} 

내가 뭘 잘못하고있어?

답변

0

게시 할 때 사용자가 URL에 없으므로 경로 정의와 일치하지 않을 것입니다.

+0

POST 메서드에 추가가 필요하다는 것을 다시 확인하십시오. –

+0

이 답변이나 댓글에 대한 답변입니까? – harishr

+0

add 메소드는 @POST로 주석 처리되므로 사용자는 URL에있을 필요가 없습니다. – user3350171

관련 문제