Jax-Rs Webservice无法正常工作

时间:2015-08-28 15:45:51

标签: java web-services rest tomcat7

您好按照本教程(https://www.youtube.com/watch?v=n_agJFIB9bw)创建REST webservice.but获取错误。 我的web.xml

<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Restful Web Application</display-name>

<servlet>
    <servlet-name>jersey-serlvet</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>com.auth</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>jersey-serlvet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

User.Java

package com.auth;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/api")
public class User {
    @GET 
    public String sayHello() {
        return "{user:ashu}";
    }

}

错误:org.apache.catalina.core.StandardWrapperValve调用 INFO:Servlet jersey-serlvet目前无法使用,

请帮忙

0 个答案:

没有答案