学习大数据——cvc-complex-type.2.4.a: Invalid content was found starting with element 'Servlet-mapping'.错误

在写web.xml文件时在< Servlet-mapping >标签中出现错误:
出现错误
代码如下:

<?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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>Web_Servlet</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>
  	<!-- 给Servlet起名称,可以任意指定,通常以类名作为其名称 -->
  	<servlet-name>HelloServlet</servlet-name>
  	<!-- 配置Servlet实现类的全类名,Servlet容器会利用反射帮我们创建对象 -->
  	<servlet-class>com.bigdata.servlet.HelloServlet</servlet-class>
  </servlet>
  <!-- 映射Servlet -->
  <Servlet-mapping>
  	<servlet-name>HelloServlet</servlet-name>
  	<!-- 配置映射的请求地址 -->
  	<url-pattern>/MyFirstServlet</url-pattern>
  </Servlet-mapping>
</web-app>

解决办法:
解决办法·
客户端服务器交互:
在这里插入图片描述

图片来自(介绍了Servlet):https://blog.csdn.net/zdb292034/article/details/81879842

发布了37 篇原创文章 · 获赞 7 · 访问量 705

猜你喜欢

转载自blog.csdn.net/qq_40394792/article/details/104161243
今日推荐