IDEA JSP include,page静态指令

it2023-08-22  67

IDEA JSP include,page静态指令

文章目录

IDEA JSP include,page静态指令一、include静态包含二、page指令1.language2.import3.contentType4.session5.buffer6.autoFlush7.isThreadSafe


一、include静态包含

<%-- Created by IntelliJ IDEA. User: ruochen Date: 2020/10/20 Time: 19:51 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>include</title> </head> <body> <h2><%@include file="hello.txt"%></h2> </body> </html>

hello.txt文件为

<%@ page contentType=“text/html;charset=UTF-8”%> 很高兴认识你们 nice to meet you

效果如图

二、page指令

作用:定义整个JSP页面的全局属性 格式: <%@ page 属性1=“属性1值”属性2=“属性2值” … %> 或 <%@ page 属性1=“值” %> <%@ page 属性2=“值” %>

可定义的常见属性: 1.language 2.import 3.contentType 4.session 5.buffer 6.autoFlush 7.isThreadSafe

1.language

<%@ page language=“java” %>

定义脚本语言,一般只能用java

2.import

<%@ page import=“java.io.*”,“java.util.Date” %>

导入需要用到的包,以便在java程序片里使用

已默认导入的值有: “java.lang.” “javax.servlet.” “javax.servlet.jsp.” “javax.servlet.http.”

3.contentType

<%@page contentType=“text/html;charset=GB2312” %>

定义jsp页面响应类型,以及字符编码格式

其默认值为:“text/html;charset=ISO-8859-1” 还可定义的值有:text/plain image/gif image/x-xbitmap image/jpeg application/vnd.ms-powerpoint application/vnd.ms-excel application/msword等

4.session

<%@page session=“true” %> 可设置ture/false。

使用内置的session对象,一般默认值是true

5.buffer

<%@page buffer=“24kb” %>

指定内置对象out的缓冲区大小,取值为none时,设置out不使用缓冲区

6.autoFlush

<%@page autoFlush=“ture” %> 可设置 ture/false 默认值是true

指定out的缓冲区填满时,缓冲区是否自动刷新。

7.isThreadSafe

<%@page isThreadSafe=“ture” %> 可设置 ture/false,默认值为true

设置JSP页面是否可多线程访问。 ture能处理多个用户的请求 false一次只能处理一个,其他的用户需要排队等候

最新回复(0)