一、页面元素概述
JSP页面的元素分为三类:(页面)指令(directiveselements),标签行为(actionselements),代码片断(scriptingelements)。
二、指令
指令是独立于每个请求的,是对整个页面有全局性影响的信息。
案例:认识指令
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%
Calendar calendar = Calendar.getInstance();
%>
now:<%=calendar.get(Calendar.HOUR_OF_DAY) %>:<%=calendar.get(Calendar.MINUTE) %>:<%=calendar.get(Calendar.SECOND) %>
</body>
</html>
三、常见的JSP页面指令
1.page页面属性指令
<%page 属性1=“属性值” 属性2=“属性值”。。。%>
(1)pageEncoding属性
说明本页面文件使用的字符编码,对于服务器正确读取文件内容很重要。
(2)import属性
用于引入外部Java程序包。
(3)session属性
(4)isELIgnored属性
2.taglib标签库指令
3.include引用外部页面指令
如果作为页面指令出现,则引用的外部页面和本页面构成新的本页面内容。
例如:
(1) <%@ include file ="test.jsp"%>
(2)<%@ include file ="NewFile1.html"%>
思考:如何通过include页面指令实现如下具备导航功能的页面效果


