【问题标题】:Why does this Spring application not work?为什么这个 Spring 应用程序不起作用?
【发布时间】:2019-12-31 19:17:37
【问题描述】:

我有this project。然后我执行以下步骤:

  1. cd spring-boot-aws-spike
  2. mvn clean compile install spring-boot:repackage
  3. cd target
  4. java -jar spring-boot-sample-0.0.1-SNAPSHOT.war
  5. 转到http://localhost:8080/
  6. 预期结果:错误消息(在浏览器中呈现)

白标错误页面

此应用程序没有显式映射 /error,因此您将其视为后备。 2019 年 8 月 27 日星期二 16:59:23 CEST 出现意外错误(类型=未找到,状态=404)。 没有可用的消息

如何更改附加的代码,以便呈现文件 index.xhtml 而不是此错误?

更新 1: 如果我转到 http://localhost:8080/index.html,我会收到此错误:

白标错误页面 此应用程序没有 /error 的显式映射,因此您将其视为后备。

2019 年 8 月 27 日星期二 17:07:53 CEST 出现意外错误(类型=未找到,状态=404)。 没有可用的消息

看起来和以前一样。

【问题讨论】:

  • 发布您的控制器代码,否则很难识别问题。
  • @Shubh 我需要一个控制器来呈现一个简单的 XHTML 页面吗?
  • 对不起,我没有在你分享的链接上看到你的代码,我的意思是你应该发布一些相关的代码,比如你正在做什么来在你的项目中呈现一个页面
  • @DP_ 您正在尝试使用java -jar 命令执行war 文件。不确定它会起作用。您需要在 TomcatPayara 等容器中运行它...

标签: java spring spring-boot


【解决方案1】:

此示例似乎不完整(缺少某些代码)。运行后我在日志中得到了它:

2019-08-27 17:19:42.119 ERROR 12588 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[facesServlet]         : Servlet.service() for servlet [facesServlet] in context with path [] threw exception [/file:/D:/workspace/spring-boot-sample-master/target/spring-boot-sample-0.0.1-SNAPSHOT.war*/index.xhtml @7,8 <p:> Tag Library supports namespace: http://xmlns.jcp.org/jsf/passthrough, but no tag was defined for name: ] with root cause

javax.faces.view.facelets.TagException: /file:/D:/workspace/spring-boot-sample-master/target/spring-boot-sample-0.0.1-SNAPSHOT.war*/index.xhtml @7,8 <p:> Tag Library supports namespace: http://xmlns.jcp.org/jsf/passthrough, but no tag was defined for name:

当您从 index.xhtml 中删除缺少的标记声明时它可以工作(仍然必须直接指向 index -> http://localhost:8080/index.xhtml):

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">

    <div class="row">
        Heyo!
    </div>
</ui:composition>

【讨论】:

    猜你喜欢
    • 2013-01-26
    • 2016-04-20
    • 2015-05-21
    • 2022-01-17
    • 1970-01-01
    • 2022-01-28
    • 2013-08-09
    • 2015-09-22
    • 1970-01-01
    相关资源
    最近更新 更多