<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>
以上是 Tomcat 的 web.xml
的片段。 URL 模式 *NEXTEVENT*
在启动时抛出
java.lang.IllegalArgumentException: Invalid <url-pattern> in servlet mapping
如果有人能指出错误,将不胜感激。
最佳答案
<url-pattern>*NEXTEVENT*</url-pattern>
URL 模式无效。它可以以星号结尾或以星号开头(表示文件扩展名映射)。
url-pattern 规范:
- 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.
参见 Java Servlet Specification 的第 12.2 节3.1 版了解更多详情。
关于tomcat - java.lang.IllegalArgumentException : Invalid <url-pattern> in servlet mapping 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26732/