【问题标题】:404 error with index.html fileindex.html 文件出现 404 错误
【发布时间】:2014-02-14 14:50:16
【问题描述】:

我在运行项目时收到 404 错误,我的 JBoss 服务器运行正常。

这里是index.html:

<html>
<body>

<form action="/services/customers" method="post">
First Name: <input type="text" name="firstname"/><br/>
Last Name: <input type="text" name="lastname"/><br/>
<INPUT type="submit" value="Send">
</form>

</body>
</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" xmlns:web="http://java.sun.com/xml/ns/javaee/web- app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>SIMS</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resteasy</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.wcs.rs.Application</param-name>
<param-value>org.jboss.samples.webservices.MyRESTApplication</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
</web-app>

这是我的文件结构:

当我运行这个项目时,我得到一个 404 错误

http://localhost:8080/SIMS/

我也试过了:

http://localhost:8080/SIMS/index.html

这也给了 404 关于如何让项目运行的任何想法?

【问题讨论】:

    标签: java html http-status-code-404 web.xml file-structure


    【解决方案1】:

    尝试输入 localhost 并从浏览树中选择您的文件

    【讨论】:

    • 所以我应该只拥有localhost:8080 并从其位置启动文件?抱歉只是不太清楚你的意思
    • 是的,试试吧。/我不确定,但你应该可以使用本地主机,我从来不用在我的端口上输入。
    【解决方案2】:

    我认为问题出在&lt;url-pattern&gt;。 jsf 库找不到你的页面。

    尝试将您的 &lt;url-pattern&gt; 更改为 &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;

    然后将&lt;welcome-file&gt;重命名为index.jsf并在index.html旁边创建一个空的index.jsf文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-13
      • 1970-01-01
      • 2015-05-17
      • 1970-01-01
      • 1970-01-01
      • 2020-07-20
      • 2021-01-05
      • 2014-05-08
      相关资源
      最近更新 更多