如何在地址栏中显示欢迎文件的完整页面URL [英] How to show full page URL of welcome file in address bar

查看:112
本文介绍了如何在地址栏中显示欢迎文件的完整页面URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有"/pages/index.xhtml"页面.问题是当我运行该应用程序时,该索引页名称没有出现在地址栏中.

I have "/pages/index.xhtml" page. The problem is when i run the application, this index page name doesn't appears at address bar.

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

有什么解决办法吗?

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

here is my welcome file from web.xml

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

推荐答案

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

You need to send a redirect from / to /pages/index.xhtml. Easiest is to use a real index file with a meta refresh header for this.

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

First create a /index.xhtml file as follows:

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

然后按如下所示更改您的<welcome-file>:

Then change your <welcome-file> as follows:

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

这也可以立即修复您使用<welcome-file>的错误方式.不应指定主页",而应指定在URL中请求诸如//foo/之类的文件夹而不是文件时需要提供的文件夹自己的文件.

This also instantly fixes your bad way of using <welcome-file>. It's not supposed to specify the "home page", but it's supposed to specify the folder's own file which needs to be served when a folder such as / or /foo/ is requested in URL instead of a file.

  • How to use a sub-folder as web.xml welcome directory
  • why do i get the protected page instead of the login page?

这篇关于如何在地址栏中显示欢迎文件的完整页面URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆