2014-06-13 1 views
0

내가 내 REST 서비스 호출 내부 Ajax 요청이 방법REST 서비스 호출에서 입력 매개 변수를받는 방법은 무엇입니까?

$.ajax({ 
      type: 'GET', 
      url: 'http://hosti[:8080/OrderSnacks/oms/toppings?topping=' + id_attr_val, 
      jsonpCallback: 'jsonCallback', 
      cache: true, 
      dataType: 'jsonp', 

      jsonp: false, 
      success: function (response) { 
      console.log(response); 
      }, 
      error: function (e) { 
       $("#divResult").html("WebSerivce unreachable"); 
      } 
     }); 
}); 

을 수행하고, 나는 내가

public String getData(@QueryParam("toppingid") String toppingid) { 
} 

public String getData(@PathParam("toppingid") String toppingid) { 

} 
입니다 모든 옵션을 시도

@Path("/toppings") 
public class ToppingService { 
    @GET 
    @Consumes("application/text") 
    @Produces("application/json") 
    public String getData(@PathParam("toppingid") String toppingid) { 
     return ""; 
    } 

이 매개 변수를받을 수 없습니다입니다

하지만 아무 것도 작동하지 않습니다.

이러한 매개 변수를받는 방법을 알려주십시오.

답변

2

문제가 있습니다. 토핑을 보내지 만 토핑 시드을 요청하십시오.

+0

감사합니다. QueryParam 또는 PathParam을 사용해야합니까 – Pawan

+0

귀하의 경우에는 PathParam을 사용하십시오. 차이점을 확인하십시오. http://stackoverflow.com/a/11569077/1392463 – Ioan

+0

대단히 감사합니다. – Pawan

관련 문제