泽西岛404错误

时间:2017-10-16 19:29:37

标签: jersey

您好我是Rest API的新手,通过关注我尝试执行Jersey程序的视频。但得到错误404,请教育我。 当我尝试在Tomcat 07v中执行时 http://localhost:8080/rws/rest/messages 我收到404错误。

MyResource类:

package org.uv;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

@Path("/messages")
public class MyResource {
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String getMessages(){
        return "Hello World";
    }

}

的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>rws</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>org.uv</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>Jersey REST Service</servlet-name>
<url-pattern>*/rest/*</url-pattern>
</servlet-mapping>
</web-app>

0 个答案:

没有答案