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...