gpt4 book ai didi

java - 如何接收REST服务调用中的输入参数?

转载 作者:行者123 更新时间:2023-12-02 05:44:39 24 4
gpt4 key购买 nike

我正在以这种方式执行 AJAX 请求

 $.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");
}
});
});

在我的 REST 服务调用中,我无法接收此参数

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

我已经尝试了所有选项

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

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

}

但是没有任何效果。

您能告诉我如何接收这些参数吗?

最佳答案

您遇到问题:您发送topping,但要求toppingid

关于java - 如何接收REST服务调用中的输入参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24208894/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com