The servlets named [x] and [y] are both mapped to the url-pattern [/JServlet] which is not permitted
来源:互联网 发布:韶关网络销售传销案件 编辑:程序博客网 时间:2024/05/15 07:27
原创文章,转载请注明出处:http://blog.csdn.net/moushao/article/details/55194141
前言:保证web.xml的配置无误,无重复
解决两个错误:1 the servlets named [cn.itcast.servlet.resource.HServlet] and [cn.itcast.servlet.resource.JServlet] are both mapped to the url-pattern [/JServlet] which is not permitted
2 the servlets named [JServlet] and [cn.itcast.servlet.resource.JServlet] are both mapped to the url-pattern [/JServlet] which is not permitted
其实这两个错误指的都是一个意思,HServlet和JServlet都指向了同一个映射,也就是说,你明明写了两个不同的服务,但是映射的,是同一个服务。
正文
最近自学i2ee,昨晚用Tomcat部属项目的时候,报了如下错误!
最开始我以为是web.xml的配置写重复了,但认真检查了两遍,发现并没有重复配置或者引用同一个影射。
后来发先是和MyEclipse有关系,我的MyEclipse的版本是2017 CI 1的,属于目前最新的版本,用以前的版本,比如2015以前的版本,采用如下图所示的方式自动创建servlet的时候,系统会自动把你创建的servlet在web.xml中配置成功。
<servlet>
</servlet>
<servlet-mapping>
<url-pattern>/HServlet</url-pattern>//地址名
</servlet-mapping>
在使用2017 CI 1版本的是时候,我在选项中并没有看到可以勾选自动配置web.xml的选项,我还以为取消了这个功能,所以自己又跑到web.xml中把servlet的配置了一遍,但事实上MyEclipse已经帮我们配置好了,如下图:
@WebServlet("/JServlet"),这一行代码,就等同上面的8行代码,MyEclipse已经帮我们自动配全。
所以,当我再到web.xml中去配置后,则给我报了前言里的第二个错,the servlets named [JServlet] and [cn.itcast.servlet.resource.JServlet] are both mapped to the url-pattern [/JServlet] which is not permitted,改正方式为,删除其中一种配置。
那第一个错更简单了,是我懒惰没有去重新new一个servlet,而是直接copy的servlet,所以,即便我把servlet的名字改了,但java文件里的配置“@WebServlet("/JServlet")” 依然和被copy的java文件配置相同,所以报了第一个错。更改方式为,修改新建服务的配置
- The servlets named [x] and [y] are both mapped to the url-pattern [/JServlet] which is not permitted
- tomcat报"The servlets named [x] and [y] are both mapped to the url-pattern[z] which is not permitted"
- The servlets named [X] and [Y] are both mapped to the url-pattern [/Z] which is not permitted
- The servlets named [] and [] are both mapped to the url-pattern [/] which is not permitted
- The servlets named [A] and [B] are both mapped to the url-pattern [/servlet/]which is not permitted
- J2EE的TOMCAT服务器报The servlets named [x] and [y] are both mapped to the url-pattern[z] which is not per
- The servlets .. are both mapped to the url-pattern [/ControllerServlet] which is not permitted
- maven创建Web项目启动错误The servlets named [X] and [Y] are both mapped to the url-pattern [/DemoServlet]
- The servlets named [xxx] and [com.web.xxx] are both mapped to the url-pattern
- The servlets named [UserExit] and [com.fxh.control.UserExit] are both mapped to the url-pattern [/Us
- The servlets named [LogRecord] and [com.action.service.imp.LogServiceImp] are both mapped to the url
- MyEclispe启动Tomcat7时出现错误The servlets named [LoginServlet] and [com.liu.control.LoginServlet] are both
- 错误解决:The type [X] is not accessible due to restriction on required library [Y].
- INS-35354] The system on which you are attempting to install Oracle RAC is not part of a valid clust
- SVN E200009 which is not part of the commit; both sides of the move must be committed together
- The string "--" is not permitted within comments.
- the binary file '***.o' is not permitted
- The string "--" is not permitted within comments.
- Hadoop学习:HDFS 机架感知
- @PathParam @QueryParam
- c++ primer 练习 1.13
- React—native+Android环境搭建和开发配置(Mac)
- python程序打包成exe
- The servlets named [x] and [y] are both mapped to the url-pattern [/JServlet] which is not permitted
- redisson实现分布式锁原理
- C++之静态成员变量和静态成员函数详解
- Android Animation动画(很详细)
- SSH做项目时经验总结 (2)
- remove ^m or show space in filename
- 怎么证明多重宇宙存在,如果它不能靠实验和观测来验证?
- 多线程
- c++ primer 练习 1.16