动作:userBean--创建对象并为对象赋值和从对象取值,但是不推荐。
<%@ page import="java.util.Date" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
</head>
<body>
动作:userBean--创建对象并为对象赋值取值,但是不推荐(容易泄露信息,并遭到攻击)
<hr>
<jsp:useBean id="user" class="com.hwadee.entity.User"></jsp:useBean>
<jsp:setProperty name="user" property="username" value="cqyddx"></jsp:setProperty>
<jsp:setProperty name="user" property="password" value="123456"></jsp:setProperty>
<jsp:setProperty name="user" property="nickname" value="cy"></jsp:setProperty>
<jsp:useBean id="user1" class="com.hwadee.entity.User"></jsp:useBean>
<jsp:setProperty name="user1" property="username" value="cqyddx1"></jsp:setProperty>
<jsp:setProperty name="user1" property="password" value="1234561"></jsp:setProperty>
<jsp:setProperty name="user1" property="nickname" value="cy1"></jsp:setProperty>
<div>
<table>
<tr><td>用户名</td></td><td>昵称</td><td>密码</td></tr>
<tr>
<td><jsp:getProperty name="user" property="username"></jsp:getProperty></td>
<td><jsp:getProperty name="user" property="password"></jsp:getProperty></td>
<td><jsp:getProperty name="user" property="nickname"></jsp:getProperty></td>
</tr>
<tr>
<td><jsp:getProperty name="user1" property="username"></jsp:getProperty></td>
<td><jsp:getProperty name="user1" property="password"></jsp:getProperty></td>
<td><jsp:getProperty name="user1" property="password"></jsp:getProperty></td>
</tr>
</table>
</div>
</body>
</html>
显示效果截图: