java示例休息程序

时间:2017-05-01 10:48:43

标签: java rest tomcat jersey

我正在尝试示例休息服务器应用程序。 我每次尝试访问服务器时都得到404。 代码细节: -

申请(战争)名称: - 休息

服务类:

package com.sandeepjn.rest.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
@Path("/services")
public class EmployeeService {
    @GET
    @Path("/{param}")
     public Response sayHello() {
        String str ="working";         
        return Response.status(200).entity(str).build(); 
    }
}

WEB-INF: -

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
    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>Rest</display-name>
    <servlet>
        <servlet-name>jersey-servlet</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.sandeepjn.rest.service</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>jersey-servlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>
</web-app>

URl用于测试: -

http://localhost:8080/Rest/rest/services/data

使用这个我总是得到404.

0 个答案:

没有答案