简体   繁体   中英

why jetty:run doesn't work with resteasy java project?

web.xml:

   <servlet>
        <servlet-name>Resteasy</servlet-name>
        <servlet-class>
            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
        </servlet-class>
        <init-param>
            <javaee:param-name>javax.ws.rs.Application</javaee:param-name>
            <javaee:param-value>com.googlecode.common.remote.pool.CommonRemotePoolApplication
            </javaee:param-value>
        </init-param>
    </servlet>
    <servlet-mapping>
        <servlet-name>Resteasy</servlet-name>
        <url-pattern>/service/*</url-pattern>
    </servlet-mapping>
    <context-param>
        <param-name>resteasy.servlet.mapping.prefix</param-name>
        <param-value>/service</param-value>
    </context-param>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

then I had

@Path("object")
public class ResourcePoolService {


    @GET
    @Path("borrow")
    @Produces(MediaType.APPLICATION_JSON)

but after I use jetty: run to start the web. then I get http://web.cn:8080/common-remote-pool/service/object/borrow doesn't work. the error is: Could not find resource for relative : /object/borrow of full path: http://web.cn:8080/common-remote-pool/service/object/borrow .

but I can get the index.jsp: http://web.cn:8080/common-remote-pool

why? how to fix it.

Your paths are missing slashes.

@Path("/object")
public class ResourcePoolService {

    @GET
    @Path("/borrow")
    @Produces(MediaType.APPLICATION_JSON)
    public Foo borrow() {

    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM