JSP渐进学习教程
<% out.println(session.getValue("name"));%>若session="false",则会出现编译错。
内容来自dedecms
errorPage属性: 本文来自织梦
指当前页面程序发生错误时,由errorPage指定的程序来处理写法:
内容来自dedecms
<%@ page errorPage="errorPage.jsp" %> copyright dedecms
如:test.jsp: <%@ page errorPage="errorPage.jsp" %>
<%!int i=0;%>
<%=7/i%>
errorPage.jsp: dedecms.com
<%@ page isErrorPage="true" %> copyright dedecms
<%=exception%>
运行test.jsp,将会看到被0除的错误信息。
dedecms.com
isErrorPage属性: 织梦好,好织梦
指明了当前程序是否为另一程序的例外处理程序。不论它是否设置,例外都会导向当前程序,问题在于当前程序能否得到此例外的对象。如设定为true,将会产生发生的例外的一个对象exception,并可以在代码中使用它;若设定了false,使用exception程序将将会在编译时出错。如:将上例的true改为false,将会出现以下错误: 织梦内容管理系统
Error:500 内容来自dedecms
Unable to compile class for JSP
织梦内容管理系统
写法:<%@ page isErrorPage="true" %> 本文来自织梦
contentType属性:
内容来自dedecms
指定了MIME的类型和JSP文件的字符编码方式,它们都是最先传送给客户端。MIME类型有:text/plain、text/html(缺省类型)、text/html、image/gif、image/jpeg、image/jpeg
dedecms.com
缺省的字符编码方式:ISO8859-1
include指令 织梦内容管理系统
作用:是用来向当前页中插入一个静态文件的内容,这个文件可能是html文件、jsp文件或其它文本文件,格式如下:
dedecms.com
<%@ include file="include.inc" %>
如: dedecms.com
native.jsp: copyright dedecms
<body>native file start here.<br> 织梦好,好织梦
<%@ include file="include.inc" %>

文章评论
共有位Admini5网友发表了评论 查看完整内容