The servlets named [LogRecord] and [com.action.service.imp.LogServiceImp] are both mapped to the url

来源:互联网 发布:python web 开发 编辑:程序博客网 时间:2024/04/30 11:19
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,所以导致出错。具体注解怎么影响以及为什么会出现冲突,下来再看看资料。。。
0 0
原创粉丝点击