如何在url-pattern错误时显示背景图像

时间:2015-05-31 19:18:34

标签: css jsf error-handling web.xml

web.xml映射

<servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

ErrorHandler servlet发出请求

RequestDispatcher view = request.getRequestDispatcher("error.jsp");
view.forward(request, response);

jsp错误页面包含样式

body {
        background-image: url(err-images/fon.png);
    }

例如,当url-pattern错误时,如何在错误页面中显示背景图像 http://localhost:8080/WEBSearchPrime_JB/wrong/register.xhtml

好吧,在leats一个解决方案是将图像上传到外部主机并使用绝对URL:)

1 个答案:

答案 0 :(得分:-2)

为错误添加单独的页面,并在web.xml文件中使用其状态端口配置错误。像这样

      <error-page>
      <error-code>400</error-code>
      <location>/WEB-INF/jsp/errorpages/ErrorPage400.jsp</location>
      </error-page> 

与错误的网址一样,它会抛出状态为404的错误消息。