A convenient configuration of servlet in intellij idea & amp; Note: intellijidea

Source: Internet
Author: User

A convenient configuration of servlet in intellij idea & Note: intellijidea

 

When writing servlet, you can add

@ WebServlet (name = "TestServlet", urlPatterns = {"/testServlet "})

This line of code can omit the servlet configuration in the web. xml file, which is really convenient.

 

Certificate -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

However, it is worth noting that whenServletAn error is reported when the name is as follows::

Error Message:

Java. lang. IllegalArgumentException: The servlets named [servlet1] and [Servlet1] are both mapped to the url-pattern [/servlet1] which is not permitted

Java. lang. IllegalStateException: ContainerBase. addChild: start: org. apache. catalina. LifecycleException: Failed to start component [StandardEngine [Catalina]. StandardHost [localhost]. StandardContext []

The complete error message is as follows::

According to the error message above, the error should be causedServlet1AndServlet1If the names are inconsistent, the two names should be namedServlet1The result is as follows:

I'm curious, why is it mandatory that the two names are the same when the servlet name is followed by a number? Here, I'll write it down for the time being, and I'll go into it later) too many...

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.