ajax - "XML Parsing Error: XML or text declaration not at start of entity"在 CentOS 中,而在 Tomcat 中运行良好

标签 ajax jsf primefaces centos

我在 AJAX 响应中的应用程序中收到如下错误。我的情况很特殊,因为我在本地 tomcat 8 环境中没有收到此错误。我在本地使用 eclipse 进行部署,WAR 文件像往常一样部署在 eclipse 插件文件夹中。我使用 PrimeFaces 5.3,AJAX 响应很好。

但是,当我从 eclipse 导出 WAR 并将 WAR 直接部署到 CentOS DEV 服务器的 Webapps 文件夹中时,AJAX 响应格式如下。 (在 firefox 的 firebug 的 XML 选项卡中)

XML Parsing Error: XML or text declaration not at start of entity   
Location: moz-nullprincipal:{f74e0a57-357d-4282-a48b-1bdea3c08805}  
Line Number 2, Column 1:
<?xml version='1.0' encoding='UTF-8'?>
^

centos服务器在java8下运行tomcat 8。我还在 Firebug 的“响应”选项卡中看到了一件奇怪的事情。在格式错误的情况下,即使在我的源 xhtml 文件中剥离 xml 声明后,我也会在顶部看到两个 xml 标记。我在本地机器上看不到这个。
<?xml version='1.0' encoding='UTF-8'?>
<?xml version='1.0' encoding='UTF-8'?>
<partial-response id="j_id1"><changes><update 
..............

Ajax 调用是单击此按钮时。
<p:commandButton update="@form:noAgentCheck, @form:agentsWrapper,  
 @form:filters" styleClass="actionButton1 bcOrange" value="Apply" 
 actionListener="#{MessagePagerBean.applyFilter}"/>

此代码位于包含的文件中。有主模板、使用页面和使用页面中包含的文件。
<h:body>
<ui:composition template="/resources/template
/threeRowsTwoColumnsTemplate.xhtml">
<ui:define name="title">
    CellTrust SecureSMS Pulse - Pager
</ui:define>
<ui:define name="sideBar">
    <ui:include src="/jsp/pages/smssecure/sideBarPager.xhtml" />
</ui:define>
<ui:define name="body">
    <ui:include src="/jsp/pages/smssecure/pagerBody.xhtml" />
</ui:define>
</ui:composition>

问题按钮代码在 pagerBody.xhtml 中

更新:问题是因为我的 Eclipse 工作区。 WAR 文件中存在导致错误 ajax 响应的问题。通过创建一个全新的工作区并将 WAR 导出到服务器来修复。谢谢。

最佳答案

我从来没有见过 @form 的组合加上一个像这样的 id

update="@form:noAgentCheck, @form:agentsWrapper,@form:filters

这可能是非法的或导致未定义的行为。如果您使用 @form ,其中的所有内容都会更新。如果只想更新个人 id,那么只需声明不带 @form 的 id

关于ajax - "XML Parsing Error: XML or text declaration not at start of entity"在 CentOS 中,而在 Tomcat 中运行良好,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29134717/

相关文章:

javascript - jquery 防止提交时重新加载表单

java - PrimeFaces SelectOneMenu : Empty String is submitted as null

jsf - 通过预创建 FacesContext 在 Filter 中访问请求属性(在重定向之前在托管 bean 中设置)

jsf - 所需的验证取决于特定按钮在向导中不起作用

java - PrimeFaces DataTable "No records found"有记录时

ajax - 即使在页面重定向之后,如何在 Firebug 中检查 AJAX 请求?

php - 编辑和删除按钮在php,ajax中添加到服务器端数据表

php - Laravel 5.2 使用 AJAX 更新表并添加新记录,无需重新加载页面

jsf - Spring webflow & PrimeFaces 表达式语言-bean 方法被解释为 websphere 中的属性而不是 tomcat

java - jsf2 表内的 selectonemenu