我正在尝试访问我的 Hello world(目前)应用程序上的资源。但是,我得到了这个 HTTP 状态 404 - 当我在 Tomcat 上部署它并点击 URL 时找不到它:localhost:8080/test/rest。这是我的 pom.xml 依赖项:
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
<version>2.26-b03</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.26-b03</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.26-b03</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
这是我的 web.xml 配置:
<web-app>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>HelloWorld Jersey Service </servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name >jersey.config.server.provider.packages</param-name>
<param-value >com.latin.translator.app</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name >HelloWorld Jersey Service </servlet-name >
<url-pattern >/test/*</url-pattern >
</servlet-mapping>
</web-app>
Java代码是:
@Path("/test")
public class Test {
@GET
@Produces(TEXT_PLAIN)
@Path("/rest")
public String test() {
return "Great success";
}
}
你有什么想法我做错了什么吗?
宝慕林4294392
收到一只叮咚
相关分类