[英]Java REST call using angularjs with param value
我試圖使用angularjs-在java中進行REST調用
Java代碼: -
@GET
@Path("/getData/{id}")
@Produces(MediaType.TEXT_PLAIN)
public static String getData(@PathParam("id") String id) {
//Operation
}
AngularJs REST調用 -
var response = $http.get('/projName/rest/get/getData', {params: {id: id}});
但它給了我例外 -
org.jboss.resteasy.spi.NotFoundException:無法找到完整路徑的資源:
該錯誤是由您嘗試訪問不同端點的事實引起的。 您的端點偵聽以下請求:
projName/rest/get/getData/{id}
//e.g.
projName/rest/get/getData/1
但你在打電話:
projName/rest/get/getData?id={id}
projName/rest/get/getData?id=1
你的代碼應該是:
var response = $http.get('/projName/rest/get/getData/' + id);
@GET
@Path("/getData/{id}")
@Produces(MediaType.TEXT_PLAIN)
public static String getData(@PathParam("id") String id) {
//Operation
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.