Servlet URI模式中的通配符导致HTTP错误404

时间:2019-03-01 17:29:59

标签: java servlets jersey jax-rs jetty

我正在尝试将Jetty Servlet与具有可变URI的POST请求进行映射。
我正在指定带有前缀和通配符的URI。 web.xml看起来像这样

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

         <display-name>my service
             </display-name>
             <welcome-file-list>
                 <welcome-file>myApplication/index.html</welcome-file>
                 <welcome-file>index.html</welcome-file>
             </welcome-file-list>

             <context-param>
                 <param-name>log4jConfigLocation</param-name>
                 <param-value>/WEB-INF/classes/log4j.properties</param-value>
             </context-param>

             <servlet>
                 <servlet-name>my-service</servlet-name>
                 <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
                 <init-param>
                     <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
                     <param-value>com.sun.jersey.api.core.PackagesResourceConfig</param-value>
                 </init-param>
                 <init-param>
                     <param-name>com.sun.jersey.config.property.packages</param-name>
                     <param-value>org.my.service</param-value>
                 </init-param>
                 <load-on-startup>1</load-on-startup>
             </servlet>


             <servlet-mapping>
                 <servlet-name>my-service</servlet-name>
                 <url-pattern>/processFullDictionary/*</url-pattern>
             </servlet-mapping>

         </web-app>

此映射产生HTTP错误404。 enter image description here

通过用显式URI替换通配符,可以正确映射servlet,并且不会显示错误:

<servlet-mapping>
        <servlet-name>my-service</servlet-name>
        <url-pattern>/processFullDictionary/form/sense/etym/re/xr/subEntry/note</url-pattern>
    </servlet-mapping>

我正在使用Jetty 9.4.11.v20180605作为服务器。知道可能是什么问题吗?

0 个答案:

没有答案