首页 文章

使用正确版本的Jersey但找不到servlet.ServletContainer类

提问于
浏览
0

我使用Jersey来构建RESTful Web API,我遇到了一些问题 .

我使用Jersey archive 1.19并更正了previous question中提到的servlet-class和param-name的错误 . 但是找不到的课程仍然存在 .

这次我创建的jsp页面能够访问,没有404错误 . 我没有实现任何内容 .

下面是我的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" id="WebApp_ID" version="3.0">
<display-name>AllegiantWS</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey REST Service</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>allegiantWS.rest.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>

</web-app>

我的项目名称是AllegiantWS . 可能有什么不对?

1 回答

  • 0

    url-pattern@PATH 似乎一致:

    <url-pattern>/api/*</url-pattern>
    

    这告诉容器将http://[Hostname]/api的所有请求重定向到此servlet .

    @Path("/v1/status")
    

    其余控制器将处理表单http://[Hostname]/v1/status的请求

相关问题