Web.xml中Element dispatcher is not allowed here

一、问题描述

在这里插入图片描述

二、解决方案

IDEA通过Maven构建的Web工程,默认web.xml的版本为2.3 ,由于版本太低,会导致web.xml在添加配置的时候出现问题
为了不出问题,我们可以直接将tomcat里面的web.xml头部拿过来
在这里插入图片描述
在这里插入图片描述

我们将文件的头部改为:

<?xml version="1.0" encoding="utf-8"?>
<web-app version="4.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd">

头部修改之后:
在这里插入图片描述

可以看到,已经识别标签了

posted @   别团等shy哥发育  阅读(88)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示