我正在跟踪gluon rest示例以访问rest服务器。但是我没有从服务器得到任何东西。该对象为null。那么代码有什么问题。该对象在那里并且可以通过http访问。
RestClient restClient = RestClient.create()
.method("GET")
.host("https://storage.waw.cloud.ovh.net")
.path("/v1/AUTH_17fd5ed14d1440b0abc4918f6a492bd9/dataCours/pourShema.json")
.contentType("charset=utf-8");
InputStreamInputConverter<CoursFrancaisJson> converter = new JsonInputConverter<>(CoursFrancaisJson.class);
GluonObservableObject<CoursFrancaisJson> retrieveObject = DataProvider.retrieveObject(restClient.createObjectDataReader(converter));
感谢您的回答。我尝试了一个简单的对象,但仍然无法正常工作。我做错了,但可以找到。该对象不被读取,并且始终为null。公共无效getCoursRest(){
RestClient restClient = RestClient.create()
.method("GET")
.host("https://storage.waw.cloud.ovh.net")
.path("/v1/AUTH_17fd5ed14d1440b0abc4918f6a492bd9/dataCours/pourShema2.json")
.contentType("charset=utf-8");
InputStreamInputConverter<PageJson> converter = new JsonInputConverter<>(PageJson.class);
GluonObservableObject<PageJson> retrieveObject = DataProvider.retrieveObject(restClient.createObjectDataReader(converter));
PageJson page1=retrieveObject.get();
// coursJson=retrieveObject.get();
}
public class PageJson {
private String lang;
private String explication;
private String titre;
public String getLang() {
return lang;
}
public void setLang(String lang) {
this.lang = lang;
}
public String getExplication() {
return explication;
}
public void setExplication(String explication) {
this.explication = explication;
}
public String getTitre() {
return titre;
}
public void setTitre(String titre) {
this.titre = titre;
}
public PageJson(String lang, String explication, String titre) {
this.lang = lang;
this.explication = explication;
this.titre = titre;
}
public PageJson (){};
}
感谢您的回答。为了使我的代码正常工作,我确实有很多工作要做。2个问题成为可观察类的类应该仅包括typeProperty(stringproperty)而不是仅仅type(string),并且注释是必填项?
如何实现其他班级的名单?是listProperty还是只是列表以及操作方式。字段类也必须实现typeproperty吗?
我做了这样的事情,但是没有功能
public void setPage(List<Page> pages){
this.page.setAll(pages);
}
@XmlList
public ListProperty<Page> getPageProperty() {
return page;
}
public List<Page> getPage(){
return page.sorted();
}