【发布时间】:2016-09-01 15:08:54
【问题描述】:
我在使用项目设置方式加载 index.html 时遇到了一些困难 - 我的结构如下所示;
我的 web.xml 如下所示;
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
<module-name>restprj</module-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>SpringApplication</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>javax.ws.rs.Application</param-name>
<param-value>com.rest.test.demo.MyApplication</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>SpringApplication</servlet-name>
<url-pattern>/service/*</url-pattern>
</servlet-mapping>
</web-app>
我可以毫无问题地调用我的休息端点 - 例如
http://localhost:8080/service/entry-point/test2/hi
这给了我输出 - 但是如果我导航到 url http://localhost:8080/service/ 我得到一个 404 - 我将 index.html 放在哪里没有区别 - 有人能指出我做错了什么吗?
谢谢
【问题讨论】: