【问题标题】:Restful web services with tomcat 8带有tomcat 8的宁静Web服务
【发布时间】:2018-04-21 15:40:33
【问题描述】:

我正在尝试制作一个简单的宁静 Web 服务示例,但它对我不起作用。首先,我使用的是 Netbeans,我使用的是 tomcat 8.5.20 和 Java EE 7 web,我只有两个类。一个是这样的: enter image description here 另一个是这样的: enter image description here

我的 intex.html 除了正常的东西之外什么都没有,而我的 context.xml 就是这样: context.xml image

就是这样。

Web 服务在我的计算机上运行得非常好,但是,当我将它部署到使用 Apache Tomcat 6.0.45 的服务器中时,我遇到了 404 错误,我不知道为什么,因为它与我使用的路径相同我在我的电脑上证明了这一点。 When i use the web service in my pcWhen i prove it in the server.

感谢您的帮助,抱歉英语不好:v

【问题讨论】:

  • 请提供您正在使用的 Netbeans 版本,并将类代码复制为文本(缩写为仅显示相关部分)而不是图像(即使没有描述...),以便我们更好地为您提供帮助。
  • 好的,谢谢,我是新手,所以我不知道如何很好地使用它

标签: web-services http netbeans tomcat7 http-status-code-404


【解决方案1】:

Nebeans 版本:8.2

第 1 类:

import rest.Consumo;
import co.edu.udea.exception.OrgSistemasSecurityException;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

@Path("/semestres")
public class HistoriaAcademicaResource {

   @GET
   @Path("/hola")
   @Produces(MediaType.TEXT_PLAIN)
   public String hola()  {
      return "Don't give up";
   }
}

第 2 类:

import javax.ws.rs.core.Application;
@javax.ws.rs.ApplicationPath("prueba")
public class ApplicationConfig extends Application {
}

索引:

<html>
    <head>
        <title>SIRVE MALDITA SEA</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
    </head>
    <body>
        <div>SIRVE PLOX</div>
    </body>
</html>

上下文.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/pruebaREST"/>

【讨论】:

    猜你喜欢
    • 2016-12-17
    • 1970-01-01
    • 2013-07-29
    • 2015-07-19
    • 2019-03-17
    • 2013-12-07
    • 1970-01-01
    • 1970-01-01
    • 2014-04-06
    相关资源
    最近更新 更多