Tomcat啟動時,自己部署的WEB APP啟動失敗,幫看看這個web.xml是否有問題
自己寫了個Servlet的配置,目的是把所有.jsp結尾的url訪問都轉到指定的Servlet。在web.xml的配置如下:
<servlet-mapping>
<servlet-name>simpleServlet</servlet-name>
<url-pattern>/*.jsp</url-pattern>
</servlet-mapping>
但是把APP部署到Tomcat,啟動Tomcat時,這個部分報了錯誤:
2008-8-1 16:01:49 org.apache.catalina.startup.ContextConfig applicationConfig
嚴重: Parse error in application web.xml
java.lang.IllegalArgumentException: Invalid <url-pattern> /*.jsp in servlet mapp
ing
at org.apache.commons.digester.Digester.createSAXException(Digester.java
:2540)
at org.apache.commons.digester.Digester.createSAXException(Digester.java
:2566)
是不允許這樣的通配符匹配嗎?
使用的Tomcat是5.0.28版本的,在WIN XP上。
《解決方案》
<url-pattern>/*.jsp</url-pattern> 有問題
去掉 / 試試
• A string beginning with a 『/』 character and ending with a 『/*』 postfix 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.
1. /path[/*]用於路徑匹配
2. *.ext用於後綴匹配