zoukankan      html  css  js  c++  java
  • web.xml中错误页面的配置

    原文:https://blog.csdn.net/bao19901210/article/details/23370407

    1.错误页面是html时的配置

    <error-page>
        <error-code>403</error-code>
        <location>/403.html</location>
    </error-page>
    <error-page>
        <error-code>404</error-code>
        <location>/404.html</location>
    </error-page>

    2.错误页面时jsp时的配置

    <error-page> 
        <error-code>500</error-code> 
        <location>/500.jsp</location> 
    </error-page>

    3.如果错误页面是jsp时,需要把该jsp文件的isErrorPage属性设置为true

    <%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8" isErrorPage="true"%>

    4.jsp错误页面内如何获取异常信息并输出

    <%@page import="java.io.PrintStream"%>
    <%@page import="java.io.ByteArrayOutputStream"%>
    <%@ include file="WEB-INF/views/includes/tags.jsp"%>
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8" isErrorPage="true"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>500 服务器内部错误</title>
    </head>
    <body>
     <div class="ui-alert-panel">
            <h1>服务器内部错误</h1>
            <p>处理您的请求时发生错误!请确认您通过正确途径操作。</p>
     </div>
      <div style="display:none;">
      <%  //此处输出异常信息
          exception.printStackTrace();
          ByteArrayOutputStream ostr = new ByteArrayOutputStream();
          exception.printStackTrace(new PrintStream(ostr));
          out.print(ostr);
      %>
      </div>
    </body>
    </html>
  • 相关阅读:
    ABP 往前端返回详细的错误信息
    ABP 报错1
    three.js 测试1
    three.js 添加 图形控制界面 gui
    three.js 设置透明度
    three.js 基础使用1
    three.js 添加环境光
    three.js 添加三维坐标系
    P2690 接苹果
    [USACO08FEB]修路Making the Grade
  • 原文地址:https://www.cnblogs.com/luna-hehe/p/14522442.html
Copyright © 2011-2022 走看看