Почему я получаю сообщение об ошибке 404 (запрошенный ресурс недоступен) на Tomcat 7.0.70, когда мой HTML-файл находится в папке WebContent?

Я продолжаю получать сообщение об ошибке 404 при попытке доступа к файлу HTML в моем динамическом веб-проекте.

Вот мой web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app
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("/inspiration")
public class Endpoints {

@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getInspiration() {
    Inspiration inspiration = InspirationFactory.generate();

    Gson gson = new Gson();
    String result = gson.toJson(inspiration, Inspiration.class);

    return Response.ok(result, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/test")
@Produces(MediaType.TEXT_PLAIN)
public Response testConnection() {
    return Response.ok("Sucess! Service is running.", MediaType.TEXT_PLAIN).build();
    }
}
0.xsd" id="WebApp_ID" version="3.0"> <display-name>NMWebServices</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> <servlet> <servlet-name>NMServlet</servlet-name> <servlet-class> com.sun.jersey.spi.container.servlet.ServletContainer </servlet-class> <init-param> <param-name>com.sun.jersey.config.property.packages</param-name> <param-value>com.nilaymodi.services</param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>NMServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping> </web-app>

мой html-файл:

<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Inspiration Generator</title>
</head>
<body>
    <p>testing</p>
</body>
</html>

мой класс обслуживания Java Rest

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("/inspiration")
public class Endpoints {

@GET
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response getInspiration() {
    Inspiration inspiration = InspirationFactory.generate();

    Gson gson = new Gson();
    String result = gson.toJson(inspiration, Inspiration.class);

    return Response.ok(result, MediaType.APPLICATION_JSON).build();
}

@GET
@Path("/test")
@Produces(MediaType.TEXT_PLAIN)
public Response testConnection() {
    return Response.ok("Sucess! Service is running.", MediaType.TEXT_PLAIN).build();
    }
}

который отлично работает по адресу "localhost:8080/apps/inspiration/"

мой корень контекста - это «приложения», и я пытаюсь попасть в файл HTML с URL-адресом «localhost: 8080/apps/inspiration.html», который является URL-адресом, который дает eclipse, когда я щелкаю правой кнопкой мыши файл HTML и запускаю на сервере . Я использую Tomcat v7.0.70

Будем очень благодарны любой помощи!


person nmodi    schedule 18.07.2016    source источник


Ответы (1)