Java WildFly 正在运行,项目已部署,但 404

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21537154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 09:14:20  来源:igfitidea点击:

WildFly running, project deployed, but 404

javajsfwildfly

提问by user2582318

i cant understand why for the project it return 404 or cant connect to the host, since the wildfly start page open perfectly

我不明白为什么该项目返回 404 或无法连接到主机,因为 Wildfly 起始页面打开完美

My web.xml

我的 web.xml

<?xml version="1.0"?>
<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">
 <display-name>HelloWorld</display-name>
 <!--
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
  </welcome-file-list>
-->
 <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>*.jsf</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.faces</url-pattern>
 </servlet-mapping>
  <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>*.xhtml</url-pattern>
 </servlet-mapping>
 <servlet-mapping>
  <servlet-name>Faces Servlet</servlet-name>
  <url-pattern>/faces/*</url-pattern>
 </servlet-mapping>
</web-app>

enter image description here

在此处输入图片说明

采纳答案by Tomaz Cerar

Your application is avalibale at

您的申请可在

http://localhost:8080/HelloWorld

as you can see also in your log. entry "register web context: /HelloWorld"

你也可以在你的日志中看到。条目“注册网络上下文:/HelloWorld”

回答by jefmaus

If the answer of ctomcdoes not work, you need create a file jboss-web.xml in /webapp/WEB-INF directory, with the next content:

如果ctomc的答案不起作用,则需要在 /webapp/WEB-INF 目录中创建一个文件 jboss-web.xml,其内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<jboss-web version="13.0"
    xmlns="http://www.jboss.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee http://www.jboss.org/schema/jbossas/jboss-web_13_0.xsd">
    <context-root>/ContextProject</context-root>
</jboss-web>

remember to change the version of wildfly that you use, and specify the context in which your application runs "ContextProject"

请记住更改您使用的 wildfly 版本,并指定您的应用程序运行“ContextProject”的上下文