code046.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>保存并展示</title>
</head>
<body>
<% request.setCharacterEncoding("utf-8"); %>
<jsp:useBean id="person" class="pack01.code044" scope="page"></jsp:useBean>
<jsp:setProperty property="*" name="person"/><%-- 这个是在表单控件name和类的属性name一致时,可以整体保存数据 --%>
<jsp:setProperty property="name" name="person" param="name"/><%-- param就是表单控件的name --%>
<jsp:setProperty property="age" name="person" param="age"/>
<jsp:setProperty property="sex" name="person" param="sex"/>
<jsp:setProperty property="address" name="person" param="address"/>
<table>
<tr>
<td>姓名:</td>
<td><jsp:getProperty property="name" name="person"/></td>
</tr>
<tr>
<td>年龄:</td>
<td><jsp:getProperty property="age" name="person"/></td>
</tr>
<tr>
<td>性别:</td>
<td><jsp:getProperty property="sex" name="person"/></td>
</tr>
<tr>
<td>住址:</td>
<td><jsp:getProperty property="address" name="person"/></td>
</tr>
</table>
</body>
</html>