Faces-redirect = true在JSF中 [英] faces-redirect=true in JSF

查看:87
本文介绍了Faces-redirect = true在JSF中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在JSF2中使用?faces-redirect=true,因为我想重定向用户以便更改URL.

I am using the ?faces-redirect=true in my JSF2, since I would like to redirect the user so the URL will be changed.

在JSF1.2中,我在faces-config中添加了</redirect>.

In JSF1.2 I added </redirect> in faces-config.

在JSF2中,我必须添加到我的网址return home?faces-redirect=true.

In JSF2 I have to add to my url return home?faces-redirect=true.

问题是我在URL中看到了faces-redirect=2,这是我使用</redirect>

The problem is that I see faces-redirect=2 in the URL, what I haven't seen in JSF1.2 when I used </redirect>

如何在不将其显示在浏览器URL中的情况下在操作中使用Faces-redirect?

How can I use faces-redirect in actions without displaying it in the browser URL?

我的Jar的列表:

  • antlr-2.7.6.jar
  • aopalliance-1.0.jar
  • aspectjrt.jar
  • atmosphere-compat-tomcat-0.5.jar
  • atmosphere-runtime-0.5.jar
  • commons-beanutils-1.7.0.jar
  • commons-collections-3.2.jar
  • commons-dbcp-1.2.2.jar
  • commons-digester-2.0.jar
  • commons-fileupload-1.2.1.jar
  • commons-httpclient-3.1.jar
  • commons-io-1.4.jar
  • commons-logging-1.1.1.jar
  • commons-pool-1.5.4.jar
  • dom4j.jar
  • ehcache-1.2.4.jar
  • commons-beanutils-1.7.0.jar
  • commons-collections-3.2.jar
  • commons-dbcp-1.2.2.jar
  • commons-digester-2.0.jar
  • commons-fileupload-1.2.1.jar
  • commons-httpclient-3.1.jar
  • commons-io-1.4.jar
  • commons-logging-1.1.1.jar
  • commons-pool-1.5.4.jar
  • dom4j.jar
  • ehcache-1.2.4.jar
  • hibernate-annotations.jar
  • hibernate-cglib-repack-2.1_3.jar
  • hibernate-commons-annotations.jar
  • hibernate3.jar
  • itext-1.4.8.jar
  • javassist.jar
  • javax.persistence.jar
  • jhighlight-1.0.jar
  • jsf-api.jar
  • jsf-impl.jar
  • jstl-api-1.2.jar
  • jstl-impl-1.2.jar
  • jta-1.1.jar
  • log4j-1.2.15.jar
  • mail.jar
  • mysql-connector-java-5.1.0-bin.jar
  • itext-1.4.8.jar
  • javassist.jar
  • javax.persistence.jar
  • jhighlight-1.0.jar
  • jsf-api.jar
  • jsf-impl.jar
  • jstl-api-1.2.jar
  • jstl-impl-1.2.jar
  • jta-1.1.jar
  • log4j-1.2.15.jar
  • mail.jar
  • mysql-connector-java-5.1.0-bin.jar
  • org.springframework.aop-3.0.1.RELEASE-A.jar
  • org.springframework.asm-3.0.1.RELEASE-A.jar
  • org.springframework.aspects-3.0.1.RELEASE-A.jar
  • org.springframework.beans-3.0.1.RELEASE-A.jar
  • org.springframework.context-3.0.1.RELEASE-A.jar
  • org.springframework.context.support-3.0.1.RELEASE-A.jar
  • org.springframework.core-3.0.1.RELEASE-A.jar
  • org.springframework.expression-3.0.1.RELEASE-A.jar
  • org.springframework.instrument-3.0.1.RELEASE-A.jar
  • org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar
  • org.springframework.jdbc-3.0.1.RELEASE-A.jar
  • org.springframework.jms-3.0.1.RELEASE-A.jar
  • org.springframework.orm-3.0.1.RELEASE-A.jar
  • org.springframework.oxm-3.0.1.RELEASE-A.jar
  • org.springframework.test-3.0.1.RELEASE-A.jar
  • org.springframework.transaction-3.0.1.RELEASE-A.jar
  • org.springframework.web-3.0.1.RELEASE-A.jar
  • org.springframework.web.portlet-3.0.1.RELEASE-A.jar
  • org.springframework.web.servlet-3.0.1.RELEASE-A.jar
  • org.springframework.web.struts-3.0.1.RELEASE-A.jar
  • org.springframework.aop-3.0.1.RELEASE-A.jar
  • org.springframework.asm-3.0.1.RELEASE-A.jar
  • org.springframework.aspects-3.0.1.RELEASE-A.jar
  • org.springframework.beans-3.0.1.RELEASE-A.jar
  • org.springframework.context-3.0.1.RELEASE-A.jar
  • org.springframework.context.support-3.0.1.RELEASE-A.jar
  • org.springframework.core-3.0.1.RELEASE-A.jar
  • org.springframework.expression-3.0.1.RELEASE-A.jar
  • org.springframework.instrument-3.0.1.RELEASE-A.jar
  • org.springframework.instrument.tomcat-3.0.1.RELEASE-A.jar
  • org.springframework.jdbc-3.0.1.RELEASE-A.jar
  • org.springframework.jms-3.0.1.RELEASE-A.jar
  • org.springframework.orm-3.0.1.RELEASE-A.jar
  • org.springframework.oxm-3.0.1.RELEASE-A.jar
  • org.springframework.test-3.0.1.RELEASE-A.jar
  • org.springframework.transaction-3.0.1.RELEASE-A.jar
  • org.springframework.web-3.0.1.RELEASE-A.jar
  • org.springframework.web.portlet-3.0.1.RELEASE-A.jar
  • org.springframework.web.servlet-3.0.1.RELEASE-A.jar
  • org.springframework.web.struts-3.0.1.RELEASE-A.jar
  • poi-3.2-FINAL.jar
  • primefaces-2.0.3-SNAPSHOT.jar
  • slf4j-api-1.5.11.jar
  • slf4j-log4j12-1.5.11.jar
  • spring-aop.jar

我的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_2_5.xsd"
    id="WebApp_ID" version="2.5">
    <display-name>OnBoard</display-name>
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <context-param>
        <description></description>
        <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
        <param-value>server</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:/applicationContext.xml
            classpath:/applicationContext-security.xml
            </param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.expressionFactory</param-name>
        <param-value>com.sun.el.ExpressionFactoryImpl</param-value>
    </context-param>

    <context-param>
        <param-name>com.sun.faces.forceLoadConfiguration</param-name>
        <param-value>true</param-value>
    </context-param>
    <context-param>
        <param-name>facelets.BUILD_BEFORE_RESTORE</param-name>
        <param-value>false</param-value>
    </context-param>


    <filter>
        <filter-name>Security Page Filter</filter-name>
        <filter-class>com.mycompany.servlet.SecurityFilter</filter-class>
    </filter>


    <filter-mapping>
        <filter-name>Security Page Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>


    <filter>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>PrimeFaces FileUpload Filter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

    <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>

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/primefaces_resource/*</url-pattern>
    </servlet-mapping>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
</web-app>

推荐答案

一切正常.其他的东西正在打扰它.也许春天?我不做Spring,所以我对此一无所知.至少,它在Mojarra 2.0.2 + PrimeFaces 2.1 + Tomcat 6.0.24上可以正常工作.

This looks all fine. Something else is disturbing it. Maybe Spring? I don't do Spring so I can't tell anything about it. At least, it works fine here with Mojarra 2.0.2 + PrimeFaces 2.1 + Tomcat 6.0.24.

无论如何要解决此问题,请考虑使用/WEB-INF/lib中的 jsf-api.jarjsf-impl.jar文件以及两个带有<h:commandButton outcome="otherfile?faces-redirect=true" />的简单XHTML文件创建一个全新的Web项目.然后逐步添加库/组件/映射,直到获得与原始项目相同的设置.在每个步骤中测试faces-redirect的工作情况.跟踪添加的内容,以便了解可能导致此问题的原因.

To nail this problem down anyway, consider creating a brand new web project with only jsf-api.jar and jsf-impl.jar files in the /WEB-INF/lib and two simple XHTML files with a <h:commandButton outcome="otherfile?faces-redirect=true" />. Then add libraries/components/mappings step by step until you get the same setup as the original project. Test the working of faces-redirect during every step. Keep track of what you've added so that you know what may have caused this problem.

这篇关于Faces-redirect = true在JSF中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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