package com.web.bean;
public class users {
private String uname;
private String upass;
public users() {
super();
}
public String getUname() {
return uname;
}
public void setUname(String uname) {
this.uname = uname;
}
public String getUpass() {
return upass;
}
public void setUpass(String upass) {
this.upass = upass;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="dologin.jsp" method="post">
<table align="center">
<tr>
<td colspan="2" align="center"><h2>登陆</h2></td>
<td></td>
</tr>
<tr>
<td align="right">用户名:</td>
<td><input type="text" name="uname"></td>
</tr>
<tr>
<td align="right">密码:</td>
<td><input type="password" name="upass"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登 陆"></td>
<td></td>
</tr>
</table>
</form>
</body>
</html>
<%@page import="com.web.bean.users"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="myUser" class="com.web.bean.users" scope="page"/>
<hr>
<!-- 通过表单匹配部分属性 -->
<jsp:setProperty name="myUser" property="uname"/>
<jsp:setProperty name="myUser" property="upass"/>
用户名:<%=myUser.getUname() %>
密码:<%=myUser.getUpass() %>
</body>
</html>