EL的简单实例

输入页面

<%@ page language="java" contentType="text/html;charset=gb2312" %>
<script type="text/javascript">
	function on_submit()
	{
		if(form1.username.value=="")
		{
			alert("用户名不能为空!");
			// 自动把焦点切换到username的输入框
			form1.username.focus();
			return false;
		}
		if(form1.password.value=="")
		{
			alert("密码不能为空!");
			form1.password.focus();
			return false;
		}
	}
</script>
<html>
<head>
<title>输入页面</title>
</head>
<body>
	<form action="acceptform.jsp" method="post" name="form1" οnsubmit="return on_submit()">
		<table style="margin:auto ;margin-top:200px" >
			<tr>
				<td colspan="2" align="center">请输入数据:</td>
			</tr>
			<tr>
				<td>用户名:</td>
				<td><input type="text" name="username"></td>
			</tr>
			<tr>
				<td>密码:</td>
				<td><input type="password" name="password"></td>
			</tr>
			<tr>
				<td colspan="2" align="center"><input type="submit" value="提交"></td>
			</tr>
		</table>
	</form>
</body>
</html>

输出页面

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>输出页面</title>
</head>
<body>
	接收到的用户名:${param.username }<br>
	接收到的密码:${param.password }
</body>
</html>

你可能感兴趣的:(Java)