【Servlet】The servlets named [ByteServlet] and [content.ByteServlet] are both mapped to the url-pattern [ByteServlet] which is not permitted

创建时间:6.30

The servlets named [ByteServlet] and [content.ByteServlet] are both mapped to the url-pattern [/ByteServlet] which is not permitted

报这个错误的原因是:Servlet注解和web.xml中url-pattern配置冲突

前段时间学Servlet时,总会碰到这个问题

 

看了控制台,发现是重复配置url-pattern的原因。但我自己并没有配置

 

 

 

后来发现原因是,创建web项目时选择的web版本是2.5,而且勾上了自动生成web.xml,在写Servlet时又加上了注解,反复配置了两次url-pattern

 

 

 

web.xml中:

 

 

 

解决方法:删除其中一个即可。但如果版本选的是2.5,自动生成web.xml没有勾上,在项目管理器里创建Servlet还是会帮你自动配置,所以建议不写注解。

 

项目管理器创建Servlet:

原文地址:https://www.cnblogs.com/musecho/p/11237180.html