JSP page指令相关属性

来源:互联网 发布:js array 编辑:程序博客网 时间:2024/05/21 10:56

一、JSP 指令

JSP 指令影响由 JSP 页面生成的 servlet 的整体结构。在 JSP 中,主要有3种类型的指令:page,include 和 taglib。

include指令,允许在JSP转换成servlet时把一个文件插入到JSP页面中。taglib指令,用来定义自定义标签。

page指令,用来定义JSP全局属性。

二、page指令属性

1. import属性:指定 JSP 页面转换成的 servlet 应该导入的内容,这些内容作用于程序段,表达式,以及声明。

<%@page  import="package.class" %>

2.session属性:设置页面的HTTP session 是否有效

<%@page  session="true" %>
<%@page session="false" %>

3.isElgnored属性:这个没弄明白,跟jsp版本什么的有关

<%@page  isEIgnored="true" %>
<%@page isElgnored="false"%>

4.buffer属性:buffer的大小被out对象用于处理执行后的jsp对客户端浏览器的输出。

<%@page  buffet="sizekb" %>
<pre name="code" class="html" style="font-size: 14px; font-weight: bold; line-height: 25.2px;"><%@page  buffet="8kb" %>
<pre name="code" class="html" style="font-size: 14px; font-weight: bold; line-height: 25.2px;"><%@page  buffet="none" %>

5.autoFlush属性:跟上面的buffer有关,antoFlush表示在buffer溢出之后是强制输出(自动清空缓存区),还是给你直接抛个异常算球。

<%@page  autoFlush="true" %>
<%@page  autoFlush="false" %>

6.info属性:这个属性被设置之后,比如<%@ page info="text"%>,然后你就可以通过Servlet.getServletInfo()这个方法获取这个字符串,这个字符串在执行JSP的时候会逐字加入JSP中。

<%@page  info="TextForYouWant" %>

7.errorPage属性:表示这个页面出错之后,会弹到的页面

<%@page  errorPage="error.jsp" %>

8.isErrorPages属性:表示这个页面是否可以作为  出错处理页面(就是让别的页面出错之后弹过来)

<%@page  isErrorPage="true" %>

<%@page  isErrorPage="false" %>

9.isTreadSafe属性:设置这个页面是否可以被多个用户访问(有的说能否被多线程使用,有的说能否都被并行访问,一个意思)

<%@page  isErrorPage="false" %>

10.extends属性:表明JSP编译时需要加入的JAVA class 的全名,(有的说设定属性指定 JSP 页面所生成的 servlet 的超类(superclass )),用的少,用时很慎重,弄不明白什么玩意儿。

<%@page  isErrorPage="false" %>

11.language属性:声明脚本语言种类,继承开发环境自动给你写了,目前只能是java.

12.contentType属性:contentType参数指定http响应的头部的Contenr-Type值,客户端浏览器会根据参数显示servlet输出的内容。

使用时有两种写法:<%@ page contentType="MIME-TYPE"%> 与 <%@ page contentType="MIMR-TYPE;charset=charsetType"%>

<%@page  contentType="application/msword" %>
<%@page  contentType="application/pdf" %>
<%@page  contentType="application/vnd.ms-excel" %>
<%@page  contentType="audio/x-wav" %>
<%@page  contentType="Text/html" %>
<%@page  contentType="Text/css" %>
<%@page  contentType="Text/plain" %>
<%@page  contentType="image/jpeg" %>
<span style="font-size: 14px;"><span style="font-family:Consolas, Bitstream Vera Sans Mono, Courier New, Courier, monospace;"><span style="line-height: 15.4px; white-space: pre;"></span></span></span><pre name="code" class="html" style="line-height: 25.2px;"><%@page  contentType="video/mpeg" %>



0 0
原创粉丝点击