大家好,目前正在开发一个需要解析 xml 文档以便对用户进行身份验证的应用程序。我使用 java.net.* 包的 URLConnection 类连接到特定的 URL,该 URL 以 xml 格式返回其响应。当我尝试使用 jdom 解析文档时,出现以下错误:
org.jdom2.input.JDOMParseException: Error on line 1: Premature end of file
任何人都可以查明问题并帮助我采取补救措施吗?谢谢,这是我的代码的一部分
try {
String ivyString = "http://kabugi.hereiam.com/?username=" + ivyUsername + "&password=" + ivyPassword;
URL authenticateURL = new URL(ivyString);
URLConnection ivyConnection = authenticateURL.openConnection();
HttpURLConnection ivyHttp = (HttpURLConnection) ivyConnection;
System.out.println("Response code ==>" + ivyHttp.getResponseCode());
if (ivyHttp.getResponseCode() != 200) {
ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Invalid username or password!", ""));
page = "confirm.xhtml";
} else {
BufferedReader inputReader = new BufferedReader(new InputStreamReader(ivyConnection.getInputStream())); …Run Code Online (Sandbox Code Playgroud)