The servlets named [LogRecord] and [com.action.service.imp.LogServiceImp] are both mapped to the url
2016-08-23 12:09
645 查看
Caused by: java.lang.IllegalArgumentException: The servlets named [LogRecord] and [com.action.service.imp.LogServiceImp] are both mapped to the url-pattern [/LogRecord] which is not permitted
I am new to sevlets and have no idea what most of the errors mean. What am I doing wrong? I have search for other questions like this on SO but the answers I found didn’t work.
This is my web.xml file:
<servlet> <servlet-name>LogRecord</servlet-name> <servlet-class>com.action.servlet.LogRecord</servlet-class> </servlet> <servlet-mapping> <servlet-name>LogRecord</servlet-name> <url-pattern>/LogRecord</url-pattern> </servlet-mapping>
@WebServlet(urlPatterns="/LogRecord") public class LogServiceImp implements LogDao{ @Override public void delete(log logi) { // TODO Auto-generated method stub } @Override public void update(log logi) { // TODO Auto-generated method stub }
answers:
It could be because"` "you're mixing the web.xml servlets configuration with the annotation based configuration"`", so check that you don't declare the same servlet in the web.xml. Based in your xml you have two options because you are configuring your servlet with annotations you can delete de tags from your web.xml. Or if you want to fix your web.xml you need to delete the start / from the servlet-name tag, it need to match with the before servlet name so: <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/HelloServlet</url-pattern> </servlet-mapping> 原因是因为我同时在注解里面和web.xml里面同时定义了url-pattern,所以导致出错。 具体注解怎么影响以及为什么会出现冲突,下来再看看资料。。。
相关文章推荐
- 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 [x] and [y] are both mapped to the url-pattern [/JServlet] 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 named [X] and [Y] are both mapped to the url-pattern [/Z] which is not permitted
- The servlets named [LoginCheckServlet] and [LoginCheckServlet] are both mapped to the url-pattern [/
- maven创建Web项目启动错误The servlets named [X] and [Y] are both mapped to the url-pattern [/DemoServlet]
- The servlets named [A] and [B] are both mapped to the url-pattern [/servlet/]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 .. are both mapped to the url-pattern [/ControllerServlet] which is not permitted
- VC编译错误:The source files "*\A.cpp " and "*\A.cpp " are both configured to produce the output file "*\
- as 导入eclipse项目报错:Error:Application and test application id cannot be the same: both are 'com.hjy.act
- MyEclispe启动Tomcat7时出现错误The servlets named [LoginServlet] and [com.liu.control.LoginServlet] are both
- The source files "*\A.cpp " and "*\A.cpp " are both configured to produce the output file "*\A.obj "
- The source files "*\A.cpp " and "*\A.cpp " are both configured to produce the output file "*\A.obj "
- Error:Application and test application id cannot be the same: both are 'com.xxxxxxx' for debugAndroi
- Why the same files are copied to /Approot and /Siteroot in Windows Azure WebRole?
- Dynamic Set Up the Web Reference Url To WebService
- Make sure the Makefile and distinfo file(/usr/ports/graphics/jpeg/distinfo) are up to date
- The database has local access protection and you are not authorized to access it locally