简体   繁体   English

RestEasy Web服务无法使用指定的URL获得响应吗?

[英]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. 我是Web服务的新手,我在RestEasy Web服务中面临一个奇怪的问题。 When i hitting the web-service URL , getting below error.Plase let me know where i am doing the mistake. 当我点击Web服务URL时,遇到error.Plause,请告诉我我在哪里出错。 Thanks, 谢谢,

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

web.xml. 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 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 resteasy.servlet.mapping.prefix添加到web.xml中。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用骆驼将Web服务响应写入文件? - How to write web-service response to file using camel? 无法访问Android中的网络服务 - Not able to access web-service in Android Http获取Web服务请求不起作用 - Http get request on web-service not working 基于从Java中的另一个异步Web服务接收到的响应来响应Web服务 - Responding to a web-service based on response received from another asynchronous web-service in Java 从Web服务中调用Web服务而不等待响应 - Calling a web-service from within a web-service and not waiting for the response 将Web服务与Java Servlet一起使用 - Using a Web-Service with Java Servlets 使用WSDL的Web服务的代理类 - proxy classes of web-service using WSDL 使用浏览器中的网址访问网络服务时,是否可以指定媒体类型?[纯粹用于测试目的] - Is there a way to specify the Media Type while hitting a web-service using a URL from browser[Purely for testing purpose] jersey:以json文件的形式接收来自Web服务的响应 - jersey : receive response from web-service as json file 使用WSDL从客户端发送到Web服务的对象在Web服务上为null,但是在客户端中不是,为什么? - Object sent from client to web-service using WSDL is null on the web-service, but not in the client, why?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM