简体   繁体   English

为什么jsf无法处理jsf错误页面?

[英]Why jsf can't handle jsf error pages?

I have an error page error.jsf mentioned in the web.xml : 我在web.xml提到了错误页面error.jsf

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>/viewExpired.jsp</location>
</error-page>
<error-page>
    <exception-type>java.lang.Throwable</exception-type>
    <location>/error.jsp</location>
</error-page>

If the file is .jsf the error page isn't triggered, when I change it to .jsp everything is OK. 如果文件是.jsf,则不会触发错误页面,当我将其更改为.jsp时,一切正常。 I've also implemented a filter but still nothing. 我还实现了一个过滤器,但仍然没有。

<filter>
    <filter-name>Error</filter-name>
    <filter-class>creazione.exception.MyFilter</filter-class>
</filter>

Is it something that JSF can't handle? 它是JSF无法处理的吗?

UPDATE The code from web.xml with the url-pattern mappings: 使用url-pattern映射更新web.xml中的代码:

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<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>dispatcher</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>

That can happen if you're actually using Facelets as default view technology, as standardized in JSF 2.0. 如果您实际上将Facelets用作默认视图技术(如JSF 2.0中标准化),则会发生这种情况。 Your question history also confirms that you're using Facelets instead of its legacy predecesor JSP. 您的问题历史记录还确认您使用的是Facelets而不是其旧的前置JSP。 You need to make those error pages Facelets files as well instead of JSP files. 您还需要创建这些错误页面Facelets文件而不是JSP文件。

That the filter is not "working" is caused by something else. 过滤器没有“工作”是由其他原因造成的。 Filters have totally no problem to run in combination with JSF. 过滤器与JSF结合使用完全没有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM