小编Rob*_*bie的帖子

我不断收到此错误,XML解析错误:语法错误,但网站仍然运行良好

我是开发网站的新手。我知道我必须在web.xml文件中映射servlet。web.xml文件是这个

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
    <display-name>TestApp</display-name>
    <welcome-file-list>
     <welcome-file>index.html</welcome-file>
     <welcome-file>index.htm</welcome-file>
     <welcome-file>index.jsp</welcome-file>
     <welcome-file>default.html</welcome-file>
     <welcome-file>default.htm</welcome-file>
     <welcome-file>default.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
     <servlet-name>Serve</servlet-name>
     <servlet-class>Serve</servlet-class>
    </servlet>
    <servlet-mapping>
     <servlet-name>Serve</servlet-name>
     <url-pattern>/TestApp</url-pattern>
    </servlet-mapping>
   </web-app>
Run Code Online (Sandbox Code Playgroud)

但是,当我调用jquery $ .ajax()函数时,出现此错误。

XML分析错误:语法错误位置:http:// localhost:8080 / TestApp / Serve 行号1,列1:

AJAX呼叫为

    $.ajax({
    url: "Serve",
    type: "POST",
    success: function(out){
        alert(out);
    },
    error: function(){
        alert("No");
    }
});
Run Code Online (Sandbox Code Playgroud)

问题是servlet仍然可以正常运行。警报(按预期)工作。请解释为什么浏览器显示错误,并请告诉我一个解决方案。

如果这是重复的问题,请提供原始问题的链接。

javascript xml ajax jquery servlets

4
推荐指数
2
解决办法
1万
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1

servlets ×1

xml ×1