在JSF RichFaces上从根目录(index.html)重定向
当我访问在JSF RichFaces上从根目录(index.html)重定向,jsf,redirect,navigation,richfaces,Jsf,Redirect,Navigation,Richfaces,当我访问http://localhost:8080/CSPPortal/index.html。根index.html包含 <html><head><meta http-equiv="Refresh" content="0; URL=pages/admin.jsf"/></head></html> faces config.xml中的导航规则如下,因为我还没有admin.xhtml的任何链接: <navigation-rule&g
http://localhost:8080/CSPPortal/index.html
。根index.html
包含
<html><head><meta http-equiv="Refresh" content="0; URL=pages/admin.jsf"/></head></html>
faces config.xml
中的导航规则如下,因为我还没有admin.xhtml的任何链接:
<navigation-rule>
<from-view-id>/pages/login.xhtml</from-view-id>
<navigation-case>
<from-outcome>result</from-outcome>
<to-view-id>/pages/result.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
/pages/login.xhtml
结果
/pages/result.xhtml
使用JBoss AS 7.1、RichFaces 4.0、JSF 2.0(通过JBoss工具)由于URL是由浏览器调用的,您需要像这样解析URL:
<meta http-equiv="Refresh" content="0; URL=#{request.contextPath}/pages/admin.jsf"/>
另见:
<html>
<head>
<meta http-equiv="Refresh" content="0; URL=index.jsf">
</head>
</html>
2.Web.xml文件
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
Facesservlet
*.jsf
外部上下文方法对我来说很好
<h:body>
#{facesContext.externalContext.response.sendRedirect('pages/admin.jsf')}
</h:body>
#{facesContext.externalContext.response.sendRedirect('pages/admin.jsf')}
当问题是路径时,您的建议有效。但这是不一样的。RichFaces x.x需要有一个index.jsf文件来处理,可以创建一个index.jsf文件并将其保留为空。这就解决了问题。
<h:body>
#{facesContext.externalContext.response.sendRedirect('pages/admin.jsf')}
</h:body>