JSP入门代码

<%@page contentType="text/html;charset=gbk" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<html>
<head>
<title>ums-modify</title>
<link href="${pageContext.request.contextPath}/style/style.css"  ref="stylesheet" type="text/css">
<script language="javascript"  src="${pageContext.request.contextPath}/js/calendar.js">
</script>
<script languge="javascript">
<!--
function validate()
{
var element = getElementByName("realName");
if(element.value.length == 0)
{
alert("请输入真实姓名!");
element.focus();
return false;
}
return true;
}
-->
</script>
</head>
<body>
<jsp:include page="/header.jsp" />
<form onsubmit="return validate()" method="post" action="${pageContext.request.contextPath}/user/modify.do">
<table>
<td>${userInfo.userName}</td>
<td>男<input type="radio" name="gender" value="1" ${userInfo.gender == "1" ? "checked" : ""}> </td>
<td>
读书<input type="checkbox" name="hobbies" value="1" ${fn:contains(userInfo.hobbies,"1") ? "checked" : ""}>
足球<input type="checkbox" name="hobbies" value="2" ${fn:contains(userInfo.hobbies,"2") ? "checked" : ""}>
<td>
</table>
</form>
<table>
<c:forEach items="${users}" var="user" varStatus="status">
<tr><td aling="center">
${status.count} </td></tr>
<tr><td aling="center">
${user.userName}</td></tr>
<tr><td aling="center">
${user.gender == "1" ? "男" : "女"}</td></tr>
<tr><td aling="center">
<a  href="${pageContext.request.contextPath}/admin/user/remove.do?id=${user.id}" onclick="return confirm('真的要删除该用户吗?')">删除</a>
</td>
</tr>
</c:forEach>
<c:if test="${empty users}">
<tr><td aling="center">
没有符合条件的用户 </td></tr>
</c:if>
</table>
<center>
<input class="button" type="button" value="返 回" onclick="self.location='${pageContext.request.contextPath}/admin/user/toquery.do'">
<input type="button" class="button" value="取 消" onclick="history.back()">
</center> 
<jsp:include page="/footer.jsp" />
</body>
</html>

原文地址:https://www.cnblogs.com/smileallen/p/3391570.html