响应主体在休息服务中为空

时间:2020-04-16 11:13:49

标签: java rest web-services jax-rs

我正在测试由JAX-WS编写的Rest服务。我执行我的服务,并且服务返回一个实体,并且我将状态ok设置为响应实体。最后,服务以代码200返回状态ok,但响应主体为空。我调试了我的代码,下面的代码行没有问题。可能是什么原因?

        var ordered_items = [];

        for(var x = 0; x < prev_tbl_rows.length; x++){

            var product = $(prev_tbl_rows[x]).find("td.one_prod_name").text();
            var quantity = $(prev_tbl_rows[x]).find("td.one_qty").text();
            var price = $(prev_tbl_rows[x]).find("td.oneprice").text();
            var subtotal = $(prev_tbl_rows[x]).find("td.oneSubtotal").text();

            ordered_items.push({
                product: product,
                quantity: quantity,
                price: price,
                subtotal: subtotal,
            });

        }

        console.log(ordered_items);

       //I don't have an idea how to retrieve each item inside this variable /*ordered_items*/ 

我的实体类是简单的Pojo:

final Entity entity = getEntity(); // i confirmed that entity is initialized and not null.
Response.ok(entity).build()

1 个答案:

答案 0 :(得分:0)

尝试一下:

Response.ok().entity(entity).build();