使用 OmniFaces ExtensionlessURLs 时是否可以防止 / 重定向到 /welcome-file

Is it possible to prevent redirecting / to /welcome-file when using OmniFaces ExtensionlessURLs

我正在使用 JSF 2.2 和 OmniFaces ExtensionlessURLs 从我的 URL 中删除文件扩展名: www.exmaple.com/appname/login.xhtml -> .../appname/login。 现在,当我导航到 www.example.com/appname/ 时,我总是被转发到 www.exmaple.com/appname/login。是否可以阻止此重定向并改为从 www.example.com/appname/?

提供 login.xhtml

我的 .xhtml 文件存储在 /WebContent/html/.

来自我的相关详细信息 web.xml:

<welcome-file-list>
   <welcome-file>login.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>
   <enabled>true</enabled>
   <async-supported>false</async-supported>
</servlet>
<servlet-mapping>
   <servlet-name>Faces Servlet</servlet-name>
   <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<context-param>
   <param-name>org.omnifaces.FACES_VIEWS_SCAN_PATHS</param-name>
   <param-value>/html/*.xhtml</param-value>
</context-param>

来自showcase

Advanced configuration

See package documentation for configuration settings as to mapping, filtering and forwarding behavior.

来自package documentation

Welcome files

If a <welcome-file> is defined in web.xml that's scanned by FacesViews AND REDIRECT_TO_EXTENSIONLESS is used (which is the default, see below), it's necessary to define an extensionless welcome file to prevent a request to / being redirected to /[welcome file]. E.g. without this http://example.com will redirect to say http://example.com/index.

For example:

<welcome-file-list>
    <welcome-file>index</welcome-file>
</welcome-file-list>

换句话说,将欢迎文件编辑为 login 而不是 login.xhtml


与具体问题无关:请注意,您似乎对“欢迎文件”的确切含义有普遍的误解,因为您可以每个文件夹中可能都有一个 login.xhtml 文件。另见 Set default home page via <welcome-file> in JSF project