带有Prettyfaces的JSF返回缓存错误页面

时间:2017-07-17 17:05:15

标签: jsf-2.2 tomcat8 prettyfaces

我正在使用JSF 2.2和tomcat 8开发一个Web应用程序,但我面临一个奇怪的问题......

例如,我有一个主页,它将调用一个managedbean,连接到数据库并返回响应。一切正常,但是,如果发生一些错误,它将重定向到我的错误页面(500.xhtml,我在我的web.xml文件中设置)。

错误发生后,我修复了错误,但我无法再访问主页,它总是将我重定向到我的500页。如果,我更改了主页的主页?任何它再次调用我的managebean并运行。此外,如果我更改服务器,从localhost更改为我的IP或127.1.0.0,它也会再次发出请求。

关注,我的web.xml。另外,我正在使用prettyfaces 3.4,不知道它是否相关但是...... Tomcat server.xml和web.xml是默认配置。

的web.xml

<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
         http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
    version="3.1">
    <servlet>
        <servlet-name>JSF Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>JSF Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
        <welcome-file>home.xhtml</welcome-file>
    </welcome-file-list>

<context-param>
    <param-name>com.sun.faces.defaultResourceMaxAge</param-name>
    <param-value>3628800000</param-value> <!-- 6 weeks. -->
</context-param>

<context-param>
    <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
    <param-value>true</param-value>
</context-param>

<mime-mapping>
    <extension>xhtml</extension>
    <mime-type>application/xml</mime-type>
</mime-mapping>
<mime-mapping>
    <extension>jsp</extension>
    <mime-type>application/xml</mime-type>
</mime-mapping>

<error-page>
    <error-code>403</error-code>
    <location>/error/403.xhtml</location>
</error-page>
<error-page>
    <error-code>404</error-code>
    <location>/error/404.xhtml</location>
</error-page>
<error-page>
    <error-code>405</error-code>
    <location>/error/405.xhtml</location>
</error-page>
<error-page>
    <error-code>500</error-code>
    <location>/error/500.xhtml</location>
</error-page>
<error-page>
    <error-code>503</error-code>
    <location>/error/503.xhtml</location>
</error-page>

Prettyfaces:

@RewriteConfiguration
public class ConfigurationProvider extends HttpConfigurationProvider {

    @Override
    public Configuration getConfiguration(final ServletContext context) {
        return ConfigurationBuilder.begin()

                .addRule(Join.path("/home").to("/"))
                .addRule(Join.path("/home").to("/home.xhtml").withInboundCorrection())
                .addRule(Join.path("/company").to("/company.xhtml").withInboundCorrection())
                .addRule(Join.path("/portfolio").to("/portfolio.xhtml").withInboundCorrection())
                .addRule(Join.path("/contact").to("/contact.xhtml").withInboundCorrection())
                .addRule(Join.path("/admin/login").to("/admin/login.xhtml").withInboundCorrection())
                .addRule(Join.path("/admin/recovery").to("/admin/recovery.xhtml").withInboundCorrection())
                .addRule(Join.path("/403").to("/error/403.xhtml").withInboundCorrection())
                .addRule(Join.path("/404").to("/error/404.xhtml").withInboundCorrection())
                .addRule(Join.path("/405").to("/error/405.xhtml").withInboundCorrection())
                .addRule(Join.path("/500").to("/error/500.xhtml").withInboundCorrection())
                .addRule(Join.path("/503").to("/error/503.xhtml").withInboundCorrection());
    }

    @Override
    public int priority() {
        return 10;
    }

}

查看firefox调试器,网络选项卡显示主页(已缓存)和301代码重定向到500的请求。

@EDIT

这似乎是漂亮的面孔。 我只是删除它,并使用chrome浏览器(没有缓存)测试,错误后,我可以再次访问该页面。然后,我再次激活prettyfaces,问题又回来了。

知道为什么吗?

0 个答案:

没有答案
相关问题