XML 解析错误:找不到元素位置:http://localhost:8081/web-app/pages/login.xhtml 第 1 行,第 1 列:^ [英] XML Parsing Error: no element found Location: http://localhost:8081/web-app/pages/login.xhtml Line Number 1, Column 1: ^

查看:46
本文介绍了XML 解析错误:找不到元素位置:http://localhost:8081/web-app/pages/login.xhtml 第 1 行,第 1 列:^的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 login.xhtml 开头为:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

我正在使用 Java 8、JSF、Primefaces、Maven、Tomcat8.我认为我的配置有问题,例如servlet 和 web.xml.

I am using Java 8, JSF, Primefaces, Maven, Tomcat8. I think that something is wrong with my configuration e.g. servlets and web.xml.

推荐答案

XML 解析错误:找不到元素位置:[...] 第 1 行第 1 列

XML Parsing Error: no element found Location: [...] Line Number 1, Column 1

这一点,这个确切的错误意味着网络浏览器检索到一个完全空的响应,同时被指示将响应解释为 XML,通常通过 Content-Type 标头,例如 application/xhtml+xmlapplication/xml,或者如果不存在,则通过 URL 中的文件扩展名,例如 .xhtml.xml.

To the point, this exact error means that the webbrowser retrieved an entirely empty response while it is being instructed to interpret the response as XML, usually via the Content-Type header such as application/xhtml+xml or application/xml, or if absent, via the file extension in URL such as .xhtml or .xml.

鉴于在请求 JSF 登录页面时会发生这种情况,这强烈表明它包含语法/运行时错误,并且 web 应用程序没有正确配置错误处理.显然,错误页面本身也被登录/安全约束所阻止,导致服务器无法显示包含所有异常详细信息的正常"错误页面,因此返回完全空的响应.

Given that this happens while requesting a JSF login page, this strongly suggests that it contained a syntax/runtime error and that the webapp doesn't have error handling correctly configured. Apparently error pages themselves are also blocked behind a login/security constraint, causing the server being unable to present a "normal" error page with all exception detail and therefore return a completely empty response.

最好的办法是读取服务器日志以了解实际异常和/或运行调试器和/或创建 JSF 异常处理程序,它显式地将异常记录到服务器日志中(以防万一您找不到异常,因此它们似乎被吞没了).一旦掌握了实际的异常,通常就是使用异常类型+消息+第一行作为关键字在网上寻找线索.

Your best bet is reading the server logs for the actual exception and/or running a debugger and/or creating a JSF exception handler which explicitly logs exceptions to server log (just in case you couldn't find exceptions and thus they appear to be swallowed). Once having the actual exception at hands, it's usually a matter of using the exception type + message + 1st line as keywords to find clues on the Internet.

这篇关于XML 解析错误:找不到元素位置:http://localhost:8081/web-app/pages/login.xhtml 第 1 行,第 1 列:^的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆