<%= ...%> 区别 <% ... %>
http://docs.oracle.com/javaee/5/tutorial/doc/bnajq.html
https://zh.wikipedia.org/wiki/JSP
Syntax Elements |
Standard Syntax |
XML Syntax |
---|---|---|
Comments |
<%--.. --%> |
<!-- .. --> |
Declarations |
<%! ..%> |
<jsp:declaration> .. </jsp:declaration> |
Directives |
<%@ include .. %> |
<jsp:directive.include .. /> |
<%@ page .. %> |
<jsp:directive.page .. /> |
|
<%@ taglib .. %> |
xmlns:prefix="tag library URL" |
|
Expressions |
<%= ..%> |
<jsp:expression> .. </jsp:expression> |
Scriptlets |
<% ..%> |
<jsp:scriptlet> .. </jsp:scriptlet>
|
A jsp:scriptlet element contains a Java program fragment called a scriptlet. This element has no attributes, and its body is the program fragment that constitutes the scriptlet.
The jsp:expression element inserts the value of a scripting language expression, converted into a string, into the data stream returned to the client. A jsp:expression element has no attributes and its body is the expression.
首先需要明确的一点是:这些都是response 之前完成的,不同的是<%= 会作为response的一部分返回;之后才会是js操作。
所以这里说的 scripting language expression 是指的java代码,而不是js
举例:
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ page isThreadSafe="true|false" %>