球衣2库response.getEntity不存在的,我应该用什么来代替

我的代码球衣2库response.getEntity不存在的,我应该用什么来代替

/* 

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

package beans;

import clients.NewJerseyClient;

import entities.ReservationItem;

import java.io.Serializable;

import java.util.ArrayList;

import java.util.Date;

import java.util.List;

import javax.faces.bean.ManagedBean;

import javax.faces.bean.SessionScoped;

import javax.ws.rs.core.GenericType;

import parameters.ReservationParam;

import org.glassfish.jersey.client.ClientResponse;

/**

*

* @author subhi2

*/

@ManagedBean

@SessionScoped

public class PageController implements Serializable {

public String moveToPage2() {

NewJerseyClient client = new NewJerseyClient();

ClientResponse response = client.findInsertedReservationItem(ClientResponse.class, "22", "2010-07-26T11:15:51", "2014-07-26T11:15:51");

GenericType<List<ReservationItem>> genericType = new GenericType<List<ReservationItem>>() {

};

// Returns an ArrayList of Players from the web service

List<ReservationItem> data = new ArrayList<ReservationItem>();

data = (response.getEntity(genericType));

return data.toString();

}

}

行 数据=(response.getEntity(genericType)); 导致错误

此代码正在与旧球衣工作,但现在应该怎么做才能解决这个错误?

回答:

对于你问我把它换成这个

response.getEntity(String.class); 

response.getEntityStream().toString(); 

但有可能是与新泽西州2相关的另一个问题,我可以得到它通过更换这些进口工作

import jersey.spi.container.servlet.ServletContainer; 

import com.sun.jersey.api.client.ClientResponse;

import com.sun.jersey.api.client.Client;

import com.sun.jersey.api.client.WebResource;

通过这些

import org.glassfish.jersey.servlet.ServletContainer; 

import org.glassfish.jersey.client.ClientResponse;

import javax.ws.rs.client.Client;

import javax.ws.rs.client.ClientBuilder;

并且在该代码(如我使用码头)我有由该

servletHolder.setInitParameter("jersey.config.server.provider.packages", 

"resources");

替换此

servletHolder.setInitParameter("com.sun.jersey.config.property.packages", 

"resources");

WebResource webResource = client.resource("http://url_u_want_to_connect"); 

ClientResponse response = webResource.accept("application/json")

通过此

WebTarget webTarget = client.target("http://url_u_want_to_connect"); 

ClientResponse response = webTarget.request("application/json")


最后这里是 “最新” 的文档的链接(这是关于新泽西2.x中,在2013年)

https://jersey.java.net/documentation/latest/user-guide.html

回答:

可以更改response.getEntity(genericType)由response.readEntity( genericType)

以上是 球衣2库response.getEntity不存在的,我应该用什么来代替 的全部内容, 来源链接: utcz.com/qa/263195.html

回到顶部