web.xml配置如下:    <!-- Spring Configuration -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:META-INF/beans.xml</param-value>
    </context-param>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <servlet>
        <servlet-name>Jersey Spring Web Application</servlet-name>
        <servlet-class>
            com.sun.jersey.spi.spring.container.servlet.SpringServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>    <servlet-mapping>
        <servlet-name>Jersey Spring Web Application</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>
如下发布没有问题,当发布类实现某个接口就不行了,访问页面直接报404错误.@Component
@Path("/test")
public class Hello {
    @Path("/getMsg")
    @GET
    @Produces("text/plain")
    public String getClichedMessage() {
        return "Hello World";
    }
}
错误的代码:@Component
@Path("/test")
public class Hello implements IHello {...}
请问大家这是什么原因?

解决方案 »

  1.   

    我的完全没有问题,呵呵:
    import javax.ws.rs.GET;
    import javax.ws.rs.Path;
    import javax.ws.rs.Produces;import org.springframework.stereotype.Component;@Component
    @Path("/test")
    public class HelloImpl implements Hello {    @Path("/getMsg")
        @GET
        @Produces("text/plain")
        public String getClichedMessage() {
            return "Hello World";
        }
    }
      

  2.   

    404 的话是不是你把资源路径弄错了?http://localhost:8080/project/services/test/getMsg是这样不?