今天復習了JSP腳本元素和注釋部分
<%! 申明語句 %>
使用申明語句的變量為全局變量
如
<html>
<head>
<title>JSP Demo</title>
</head>
<body>
<%! int a =
<%
out
a++;
%>
</body>
</html>
結果如下
再次刷新
<% Java代碼%>
在JSP Scriptlets中可包含多個語句
如
<html>
<head>
<title>test demo</title>
</head>
<body>
<%
String str = "Hello
out
%>
</body>
</html>
結果如下
<%= Java代碼 %>
一種簡單的輸出形式
如
<html>
<head>
<title>test demo</title>
</head>
<body>
<% String str = "Hello
<%= str %>
</body>
</html>
結果如下
<!
<%
如
<html>
<head>
<title>test demo</title>
</head>
<body>
<!
<%
</body>
</html>
結果如下
大家發現都沒有什麼顯示
<html>
<head>
<title>test demo</title>
</head>
<body>
<!
</body>
</html>
應該很多人都知道
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/
* Generated at:
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking
*/
package org
import javax
import javax
import javax
public final class HelloXiaoMo_jsp extends org
implements org
private static final javax
javax
private static java
private javax
private org
public java
return _jspx_dependants;
}
public void _jspInit() {
_el_expressionfactory = _jspxFactory
_jsp_instancemanager = org
}
public void _jspDestroy() {
}
public void _jspService(final javax
throws java
final javax
javax
final javax
final javax
javax
final java
javax
javax
try {
response
pageContext = _jspxFactory
null
_jspx_page_context = pageContext;
application = pageContext
config = pageContext
session = pageContext
out = pageContext
_jspx_out = out;
out
out
out
out
out
out
out
out
out
out
out
} catch (java
if (!(t instanceof javax
out = _jspx_out;
if (out != null && out
try { out
if (_jspx_page_context != null) _jspx_page_context
else throw new ServletException(t);
}
} finally {
_jspxFactory
}
}
}
From:http://tw.wingwit.com/Article/program/Java/JSP/201311/20021.html