我正在尝试在客户端解组 JAXB,但我将对象的属性设置为 NULL。
这就是我正在做的解组
URL url = new URL("http://localhost:9191/service/firstName/tony?format=xml");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/atom+xml");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
JAXBContext jaxbContext = JAXBContext.newInstance(LDAPUsers.class);
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
LDAPUsers lu = (LDAPUsers) jaxbUnmarshaller.unmarshal(br);
ArrayList<LDAPUser> list = new ArrayList<LDAPUser>();
//list.addAll(lu.getCounty());
**System.out.println(lu.ldapUser.get(0).getFirstName());//this is giving NULL**
conn.disconnect();
请帮忙!!!