【问题标题】:java.lang.IllegalArgumentException: Invalid <url-pattern> coreservlets.ShowItems_ArrayListjava.lang.IllegalArgumentException:无效的 <url-pattern> coreservlets.ShowItems_ArrayList
【发布时间】:2015-06-14 14:14:00
【问题描述】:

Eclipse 版本:Kepler Service Release 1

版本号:20130919-0819

目前采取的步骤:

(1) 删除目录下的.snap文件

<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources

(2) 删除了以下目录中的tmp文件夹

<workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core

(3) 清理项目和服务器

(4) 通过删除当前服务器重新配置服务器,并添加 新服务器

(5) 只是为了保证改动反映,每次都重启Eclipse 执行上述步骤后。

Caused by: java.lang.IllegalArgumentException: Invalid <url-pattern> coreservlets.ShowItems_ArrayList in servlet mapping
    at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3279)
    at org.apache.catalina.core.StandardContext.addServletMapping(StandardContext.java:3254)
    at org.apache.catalina.deploy.WebXml.configureContext(WebXml.java:1430)
    at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1344)
    at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:876)
    at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:374)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5355)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more

但是,所有提示和技巧似乎都徒劳无功。

web.xml 文件:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0">

    <servlet>
        <servlet-name>ShowItems_ArrayList</servlet-name>
        <servlet-class>coreservlets.ShowItems_ArrayList</servlet-class>
    </servlet>


    <servlet-mapping>
        <servlet-name>ShowItems_ArrayList</servlet-name>
        <url-pattern>coreservlets.ShowItems_ArrayList</url-pattern>
    </servlet-mapping>

</web-app>

【问题讨论】:

  • 似乎问题出在Invalid &lt;url-pattern&gt; 上。你能把你的 web.xml 贴在这里吗?
  • web.xml 文件 &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt; &lt;servlet&gt; &lt;servlet-name&gt;ShowItems_ArrayList&lt;/servlet-name&gt; &lt;servlet-class&gt; coreservlets.ShowItems_ArrayList &lt;/servletclass&gt; &lt;/servlet&gt; &lt;servlet-mapping&gt; &lt;servlet-name&gt;ShowItems_ArrayList&lt;/servlet-name&gt; &lt;url-pattern&gt;coreservlets.ShowItems_ArrayList&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; &lt;/web-app&gt;
  • @kucing_terbang - web.xml file is attached per your request.
  • 好吧,你可以通过添加斜杠来更改 url 模式(就像 Necreaux 发布的那样)

标签: eclipse tomcat url-pattern


【解决方案1】:

您的网址格式不正确。它需要以斜线开头。虽然不是完全重复,但请参阅以下问题:

Why should url-pattern in servlet mapping start with forward slash(/)

【讨论】:

    猜你喜欢
    • 2015-02-24
    • 2020-04-11
    • 1970-01-01
    • 2010-09-06
    • 2015-10-04
    • 2011-07-23
    • 2015-09-14
    • 2013-06-04
    • 2015-10-10
    相关资源
    最近更新 更多