Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

tomcat - java.lang.IllegalArgumentException: Invalid <url-pattern> in servlet mapping

<servlet>
    <servlet-name>myservlet</servlet-name>
    <servlet-class>workflow.WDispatcher</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>myservlet</servlet-name>
    <url-pattern>*NEXTEVENT*</url-pattern>
</servlet-mapping>

Above is the snippet from Tomcat's web.xml. The URL pattern *NEXTEVENT* on start up throws

java.lang.IllegalArgumentException: Invalid <url-pattern> in servlet mapping

It will be greatly appreciated if someone can hint at the error. -------------------------------

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<url-pattern>*NEXTEVENT*</url-pattern>

The URL pattern is not valid. It can either end in an asterisk or start with one (to denote a file extension mapping).

The url-pattern specification:

  • A string beginning with a ‘/’ character and ending with a ‘/*’ suffix is used for path mapping.
  • A string beginning with a ‘*.’ prefix is used as an extension mapping.
  • A string containing only the ’/’ character indicates the "default" servlet of the application. In this case the servlet path is the request URI minus the context path and the path info is null.
  • All other strings are used for exact matches only.

See section 12.2 of the Java Servlet Specification Version 3.1 for more details.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
...