Перенаправить из файла приветствия index.jsp на страницу map.xhtml JSF

Я пытаюсь сделать мой первый проект jsf2 запущенным на jboss7.1. Я хочу перенаправить из index.jsp в map.xhtml, это то, что я пытаюсь в моем index.jsp, и все они не работают, пожалуйста, помогите

<%=response.sendRedirect("map.html")  %>
<%=response.sendRedirect("/map.html")  %>
<%=response.sendRedirect("map.xhtml")  %>
<%=response.sendRedirect("/map.xhtml")  %>
<%=response.sendRedirect("map.jsf")  %>
<%=response.sendRedirect("/map.jsf")  %>

а это мои лица-config.xml

<faces-config
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns     /javaee   /web-facesconfig_2_1.xsd"
version="2.1">

</faces-config>

это мой web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee    /web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com    /xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>myproject</display-name>
  <servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

1 ответ

Решение

Не делай это трудным путем.

+ Изменить

<url-pattern>*.jsf</url-pattern>

в

<url-pattern>*.xhtml</url-pattern>

и изменить

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

в

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

Сюда map.xhtml становится файлом приветствия, и теперь вы можете перестать возиться с виртуальными URL-адресами, такими как .jsf и в качестве бонуса вы можете полностью избавиться от устаревшего файла JSP.

Другие вопросы по тегам