【问题标题】:How to show full page URL of welcome file in address bar如何在地址栏中显示欢迎文件的整页 URL
【发布时间】:2013-06-07 12:00:08
【问题描述】:

我有“/pages/index.xhtml”页面。问题是当我运行应用程序时,此索引页面名称不会出现在地址栏中。

它只显示http://localhost:8080/myApplication/。我想看的是http://localhost:8080/myApplication/pages/index.xhtml

有什么解决办法吗?

这是来自 web.xml 的欢迎文件

<welcome-file-list>
    <welcome-file>pages/index.xhtml</welcome-file>
</welcome-file-list>

【问题讨论】:

    标签: jsf url jsf-2 welcome-file


    【解决方案1】:

    您需要发送从//pages/index.xhtml 的重定向。最简单的方法是为此使用带有元刷新头的 real 索引文件。

    首先创建一个/index.xhtml文件如下:

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <title>Dummy homepage</title>
        <meta http-equiv="refresh" content="0; url=pages/index.xhtml" />
      </head>
    </html>
    

    然后将您的&lt;welcome-file&gt; 更改如下:

    <welcome-file>index.xhtml</welcome-file>
    

    这也可以立即解决您使用&lt;welcome-file&gt; 的错误方式。它不应该指定“主页”,但应该指定文件夹自己的文件,当在 URL 中请求 //foo/ 等文件夹而不是文件时需要提供该文件。

    另见

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-28
      • 1970-01-01
      • 2016-05-13
      • 1970-01-01
      • 2015-07-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多