JSP中errorPage设置方法

2016-02-19 13:18 11 1 收藏

今天图老师小编要向大家分享个JSP中errorPage设置方法教程,过程简单易学,相信聪明的你一定能轻松get!

【 tulaoshi.com - Web开发 】

1.设置errorPage:errorPage.jsp

%@page isErrorPage="true"%
html
    head
        meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
        titleJSP Page/title
    /head
    body
         Error~!
         %=exception.getMessage()%
    /body
/html

2.应用

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

%@page info="Bad page"%
%@page errorPage="errorPage.jsp" %   //出错后转到
html
    head
        meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
        titleJSP Page/title
    /head
    body
         %
               boolean tf = true;
               if(tf){
                    String info = getServletInfo();
                    throw new Exception("Exception in:" + info);
               }
         %
    /body
/html

(本文来源于图老师网站,更多请访问https://www.tulaoshi.com/webkaifa/)

来源:https://www.tulaoshi.com/n/20160219/1603744.html

延伸阅读
标签: Java JAVA基础
  为了简化JSP表达式和scriptlets中的代码,提供了8种自动定义的变量,有时称做implicit objects(固有对象)。它们是:request,response,out,session,application,config,pageContext,和 page。下面我们来详细的了解它们。 request 与request相联系的是HttpServletRequest类,使您可以得到request的参数(通过getParameter方法...
标签: Web开发
page对象代表JSP本身,更准确地说它代表JSP被转译后的Servlet,它可以调用Servlet类所定义的方法。 二、config 对象 config 对象里存放着一些Servlet 初始的数据结构。 config 对象实现于javax.servlet.ServletConfig 接口,它共有下列四种方法: public String getInitParameter(name) public java.util.Enumera...
标签: Java JAVA基础
使用PrintWriter对象即可写Text文件。 请参考以下示例: <%@ page import="java.io.*" % <% String str = "print me"; //always give the path from root. This way it almost always works. String nameOfTextFile = "/usr/anil/imp.txt"; try { PrintWriter pw = new PrintWriter(new FileOutputSt...
标签: Java JAVA基础
  预备知识: 1.字节和unicode Java内核是unicode的,就连class文件也是,但是很多媒体,包括文件/流的保存方式 是使用字节流的。 因此Java要对这些字节流经行转化。char是unicode的,而byte是字节. Java中byte/char互转的函数在sun.io的包中间有。其中ByteToCharConverter类是中调度, 可以用来告诉你,你用的Con...
标签: Java JAVA基础
  (四)Tomcat 1、用WinZIP等解压缩软件把tomcat.zip解压缩到一个目录下,我把它解压缩到C:\,它会自动 创建tomcat子目录,这样在C盘就多了一个目录C:/tomcat,我用$TOMCAT标识; 2、打开$APACHE_ROOT\conf\httpd.conf文件,在该文件最后加上类似这样一句话: Include $TOMCAT/etc/t...

经验教程

19

收藏

89
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部