gpt4 book ai didi

java - WildFly 仅返回文件名

转载 作者:行者123 更新时间:2023-12-01 06:13:35 27 4
gpt4 key购买 nike

我最近尝试使用 WildFly 而不是 TomEE 作为我的基于 JSF 的 Web 应用程序的容器。这是一个基本的应用程序,提供一个页面,该页面有几个可以保存到数据库的字段。

它在 TomEE 中运行良好,但自从我尝试使用 Maven 构建并部署到 WildFly 以来,我的运气并不好。

当我尝试导航到第一页 (http://localhost:8080/firstflight-0.0.1-SNAPSHOT/firstflight/hello.jsf) 时,WildFly 只是返回一个空白页,并打印出以下文本:

/firstflight-0.0.1-SNAPSHOT/firstflight/hello.jsp

当然,人们注意到的第一件事是它似乎找到了该页面,因为扩展名是 jsp,而不是用于请求该页面的 jsf。请求一个不存在的页面也会给出 404,所以这里肯定有什么东西在工作。

请告诉我更多信息是否有帮助,我会尽力提供。

更新:我被要求包含整个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_2_5.xsd" id="WebApp_ID" version="2.5">

<welcome-file-list>
<welcome-file>/hello.xhtml</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>

<mime-mapping>
<extension>xhtml</extension>
<mime-type>text/html</mime-type>
</mime-mapping>
</web-app>

最佳答案

URL 中出现的内容不正确。/firstflight-0.0.1-SNAPSHOT 看起来像是上传的 war 的名称,而不是网络上下文。在不知道有关您的应用程序的更多详细信息的情况下,我认为您的网址应该是 http://localhost:8080/firstflight/hello.jsp .

我还注意到,在 web.xml 中,您的欢迎页面是一个 xhtml 页面,并且您已将 servlet 映射 url 模式指定为 *.jsf。如果您的页面是 .xhtml,那么这需要是 *.xhtml,以便您的应用程序知道哪些页面是 Faces 页面,然后 url 将是 http://localhost:8080/firstflight/hello.xhtml

格雷厄姆

关于java - WildFly 仅返回文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29637061/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com