JSTL(Java标准标记库)简介
JSTL是JSP标记的集合,结合了许多JSP应用程序所共有的核心功能。JSTL支持迭代,有条件,处理数据库操作。而且它还用于操作XML,SQL。为此,您需要一个JSTL的jar文件,您可以从http://tomcat.apache.org/taglibs/index.html下载它,并将其添加到您的类路径中。如果您使用的是Eclipse,只需将它们添加到lib文件夹和buildpath中。
JSTL.jsp
这是我们接受输入的基本页面,并验证用户输入的年龄是否大于18岁。
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
<style type="text/css">
form{
text-align:center;
border:2px solid #000;
}
p{
text-align:center;
font-size: 16pt;
}
h2{
color:#216aF3;
text-decoration: underline ;
}
button{
width:100px;
font-size:16pt;
}
input[type="text"]{
font-size:16pt;
}
input[type="text"]:focus{
background-color:lightyellow;
}
</style>
</head>
<body>
<form action="jstlaction.jsp" method="post">
<h2>SIMPLE JSTL EXAMPLE</h2>
<p>Your Age:<input type="text" name="age"/></p>
<p> NAME:<input type="text" name="user" /></p>
<p>EMAIL:<input type="text" name="email"/></p><br>
<button type="submit">Validate</button><br><br><br>
</form>
</body>
</html>