jsp中errorPage、isErrorPage、和exeception
2018-04-01 22:00
375 查看
errorPage<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!--
如果程序中有代码跑出异常,既代码有逻辑错误,这个jsp页面会自动跳转到指定的错误页面:error.jsp
如果当前jsp中没有错误就正常执行代码,不会跳转到错误展示页面
-->
<%@page errorPage="error.jsp" %>
注意:这里跳转是服务器跳转
isErrorPage<%@page isErrorPage="true" %> //可以获取错误信息
<error-page>
<error-code>404</error-code>
<location>/error404.jsp</location>
</error-page>
<!-- 配置500错误,当页面出现500错误 执行下面代码 -->
<error-page>
<error-code>500</error-code>
<location>/error500.jsp</location>
</error-page>
page属性:isELIgnored
是否忽略EL表达式??
默认是false<%@ page isELIgnored="false" %> //默认是false 如果设置为true那么在本页面中EL表达式将不能正常使用!
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!--
如果程序中有代码跑出异常,既代码有逻辑错误,这个jsp页面会自动跳转到指定的错误页面:error.jsp
如果当前jsp中没有错误就正常执行代码,不会跳转到错误展示页面
-->
<%@page errorPage="error.jsp" %>
<!-- 指定错误! --> <%=1/0 %>
注意:这里跳转是服务器跳转
isErrorPage<%@page isErrorPage="true" %> //可以获取错误信息
<%=exception.getMessage()%>在XML中配置:<!-- 配置404错误,当有页面出现404错误,就跳转到下面的页面 -->
<error-page>
<error-code>404</error-code>
<location>/error404.jsp</location>
</error-page>
<!-- 配置500错误,当页面出现500错误 执行下面代码 -->
<error-page>
<error-code>500</error-code>
<location>/error500.jsp</location>
</error-page>
page属性:isELIgnored
是否忽略EL表达式??
默认是false<%@ page isELIgnored="false" %> //默认是false 如果设置为true那么在本页面中EL表达式将不能正常使用!
相关文章推荐
- 关于jsp页面page指令中errorpage和iserrorpage属性
- JSP基础 内置对象exception 设置isErrorPage=true后,才可以使用
- JSP中的errorPage和isErrorPage
- JSP中的errorPage与isErrorPage的使用
- JSP基础 指令page isErrorPage 标识当前页面是处理错误的 并 出错时返回状态码为500
- jsp: isErrorPage="true"的作用
- JSP中的errorPage与isErrorPage的使用
- JSP指令标签的练习:errorPage属性和isErrorPage属性
- JSP page指令 关于isErrorPage指定错误页面的使用
- jsp: isErrorPage="true"的作用
- JSP 404 ErrorPage 自定义页面处理
- jsp页面errorPage设定,没有跳转,出现500错误
- JSP 指定异常处理页 isErrorPage, errorPage
- JSP中errorPage无法跳转的解决办法
- errorPage与isErrorPage
- spring-boot集成 jsp报whitelabel error page的问题解决
- [error] isNewPageLoaded found an old pageLoadError: Error: Current window or frame is closed!
- jetty访问jsp页面出现PWC6345: There is an error in invoking javac. A full JDK (not just JRE) is required
- jetty访问jsp页面出现( PWC6345: There is an error in invoking javac)