package com.javaweb.test;
public class UserBean
{
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<center>
<form action="SetPropertyDemo.jsp"method="post">
<table>
<tr>
<td colspan="2">用户表单</td>
</tr>
<tr>
<td>账 号</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>密 码</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="递交">
<input type="reset" value="重置">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
<%@ page language="java" import="java.util.*" contentType="text/html;charset=gb2312" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body>
<jsp:useBean id="user" scope="page" class="com.javaweb.test.UserBean" />
<jsp:setProperty name="user" property="*"/>
<%
out.println("用户名"+user.getUsername()+"<br>");
out.println("用户密码"+user.getPassword()+"<br>");
%>
</body>
</html>