首页 > 技术文章 > JSP/Servlet及相关技术详解

wxc-kingsley 2017-08-19 11:20 原文

 

JSP声明

<%!声明部分%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>欢迎</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>
<%!
//声明一个整数变量
public int count;
/*
定义一个方法
*/
public String info(){
return "hello";
}
%>
<body>
this is my test page !
<br>
<%=count++ %>
<%=info() %>

</body>
</html>

 

 输出JSP表达式

<%=表达式%>

<%=count++ %>
<%=info() %>

替代out.println输出语句,输出表达式语法后不能有分号

 JSP脚本

JSP的3个编译指令

 JSP脚本的9个内置对象

 

推荐阅读