Я использую JSF 2.2 и OmniFaces URL без расширений, чтобы удалить расширения файлов из моих URL-адресов:
www.exmaple.com/appname/login.xhtml -> .../appname/login
.
Теперь, когда я перехожу к www.example.com/appname/
, меня всегда перенаправляют на www.exmaple.com/appname/login
. Можно ли предотвратить это перенаправление и вместо этого обслуживать login.xhtml
из www.example.com/appname/
?
Мои .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>
Из витрина:
Advanced configuration
See package documentation for configuration settings as to mapping, filtering and forwarding behavior.
Welcome files
If a
<welcome-file>
is defined inweb.xml
that's scanned by FacesViews ANDREDIRECT_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 thishttp://example.com
will redirect to sayhttp://example.com/index
.For example:
<welcome-file-list> <welcome-file>index</welcome-file> </welcome-file-list>
Другими словами, отредактируйте файл приветствия, указав login
вместо login.xhtml
.
Не связанный к конкретной проблеме: обратите внимание, однако, что у вас, похоже, есть общее непонимание точного значения «файла приветствия», потому что немного странно, что у вас может быть файл login.xhtml
в каждой отдельной папке. См. также Установите домашнюю страницу по умолчанию через <welcome-file> в проекте JSF