简体   繁体   中英

RestEasy web-service not able get the response using specified URL?

I am new to web-service.I am facing strange issue in RestEasy web-service. When i hitting the web-service URL , getting below error.Plase let me know where i am doing the mistake. Thanks,

HTTP Status 404 - Could not find resource for relative : /rest/publish of full path: http://localhost:8888/WebServiceJaskson/rest/publish 

web.xml.

   <display-name>WebServiceJaskson</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> 
<context-param>
        <param-name>resteasy.scan</param-name>
        <param-value>true</param-value>
    </context-param>

    <listener>
        <listener-class>
            org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
        </listener-class>
    </listener>

    <servlet>
        <servlet-name>resteasy-servlet</servlet-name>
        <servlet-class>
            org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
        </servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>resteasy-servlet</servlet-name>
        <url-pattern>/rest/*</url-pattern>
    </servlet-mapping>

RestEasyService.java

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;


@Path("/publish")
public class RestEasyService {

    @GET
    @Produces(MediaType.TEXT_HTML)
    public Response getRestResponse(){
        return Response.status(200).entity("<b>Rest Web Response</b>").build(); 
    }
}

You need to add the context-param resteasy.servlet.mapping.prefix to your web.xml.

<context-param>
    <param-name>resteasy.servlet.mapping.prefix</param-name>
    <param-value>/rest</param-value>
</context-param>

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