JSP 1)Java Server Page,在html中嵌入java代码 2)九个内置(隐式)对象 request response out page pageContext config session application Exception 3)JSP指令 <%@ page ... %> Page指令,定义页面属性 eg:<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%> <%@ include ... %> 包含其他文件 eg:<%@ include file="../common/comm.jsp"%> <%@ taglib ... %> 引入标签库的定义 eg:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> JSTL 1)JSP Standard Tag Libaray http://www.runoob.com/jsp/jsp-jstl.html 2)四类标签 核心(core)标签 格式化(format)标签 SQL标签 XML标签 3)标签的使用(以核心标签为例) a.在web.xml中配置 <jsp-config> <taglib> <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> <taglib-location>/WEB-INF/taglib/c.tld</taglib-location> </taglib> </jsp-config> b.在jsp页面中添加 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 4)核心标签 <c:out ></c:out> <c:set var="" value="" scope=""/> scope可选,默认为page <c:remove var="" scope=""/> 同set <c:url value="/index.jsp"/> 会自动在value前添加项目名,即project_name/index.jsp,亦等同于${pageContext.request.contextPath}/inedx.jsp的效果 <c:if test="${condition}" val="" scope=""> do something... </c:if> <c:choose> <c:when test="${condition}"> do something... </d:when> <c:when test="${condition}"> do something... </d:when> <c:when test="${condition}"> do something... </d:when> <c:otherwise> do something... </d:otherwise> </c:choose> <c:forEach var="" items=""> do something... </c:forEach> items为传入的集合,val是每一项 EL 1)Expression Language http://www.runoob.com/jsp/jsp-expression-language.html 2)十一个内置(隐式)对象 pageScope requestScope sessionScope applicationScope param paramValues header headerValues initParam cookie pageContext