一.jsp脚本和注释
- jsp脚本:
1) <%java 代码%>----------内部的java代码翻译到service 方法的内部
2) <%=java变量或表达式%>-------会被翻译成service方法内部的out.print()
3) <%java 代码%>会被翻译成servlet的成员的内容
- jsp注释:
1) Html注释: <!--注释内容-->
2) java注释: //单行注释 /*多行注释*/
3) jsp注释: <%--注释内容--%>
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 2 ??xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 3 ??<modelVersion>4.0.0</modelVersion> 4 ??<groupId>com.werner</groupId> 5 ??<artifactId>jsp2</artifactId> 6 ??<packaging>war</packaging> 7 ??<version>1.0-SNAPSHOT</version> 8 ??<name>jsp2 Maven Webapp</name> 9 ??<url>http://maven.apache.org</url>10 ??<dependencies>11 ????<dependency>12 ??????<groupId>junit</groupId>13 ??????<artifactId>junit</artifactId>14 ??????<version>3.8.1</version>15 ??????<scope>test</scope>16 ????</dependency>17 ????<dependency>18 ??????<groupId>javax.servlet.jsp</groupId>19 ??????<artifactId>javax.servlet.jsp-api</artifactId>20 ??????<version>2.3.1</version>21 ??????<scope>provided</scope>22 ????</dependency>23 ????<dependency>24 ??????<groupId>javax.servlet</groupId>25 ??????<artifactId>javax.servlet-api</artifactId>26 ??????<version>3.1.0</version>27 ??????<scope>provided</scope>28 ????</dependency>29 ????<!-- https://mvnrepository.com/artifact/javax.el/javax.el-api -->30 ????<dependency>31 ??????<groupId>javax.el</groupId>32 ??????<artifactId>javax.el-api</artifactId>33 ??????<version>3.0.0</version>34 ????</dependency>35 ????<!-- https://mvnrepository.com/artifact/javax.servlet.jsp.jstl/jstl -->36 ????<dependency>37 ??????<groupId>javax.servlet.jsp.jstl</groupId>38 ??????<artifactId>jstl</artifactId>39 ??????<version>1.2</version>40 ????</dependency>41 ????<!-- https://mvnrepository.com/artifact/taglibs/standard -->42 ????<dependency>43 ??????<groupId>taglibs</groupId>44 ??????<artifactId>standard</artifactId>45 ??????<version>1.1.2</version>46 ????</dependency>47 ??</dependencies>48 ??<build>49 ????<finalName>jsp2</finalName>50 ??</build>51 </project>
<%@page language="java" contentType="text/html;UTF-8" pageEncoding="UTF-8" %>
<%@page import="java.util.*" %>
<html>
<head>
???<meta http-equiv="content-type" content="text/html;charset=UTF-8">
???<title>Insert title here</title>
</head>
<body>
xxxxxxxxx
<!--html的注释-->
<%----%> jsp注释
<% int i=0;
???System.out.println(i);
%>
<%=i %>
<%=1+1 %>
<%!
String str ="nihao CHIAN";
%>
<%=str%>
</body>
</html>
``````````````````````````````````````````````````````````````````````````````````````````````````````````
xxxxxxxxx jsp注释 0 2 nihao CHIAN
- jsp运行原理
JSP在第一次被访问时会被WEB容器翻译成servlet,在执行过程:
第一次访问----->hellosServlet.java---->helloServlet_jsp.servlet----->编译运行PS
:被翻译后的servlet在Tomcat 的work目录中可以找到
- jap指令(3个)
jsp的指令是指导jsp翻译和运行的命令,jsp包括三大指令:
JSP技术
原文地址:http://www.cnblogs.com/1218-mzc/p/7498765.html