<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'dologin.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<!-- 实例化一个javaBeans对象 -->
<jsp:useBean id="myUsers" class="com.po.Users" scope="page"/>
<h1>setProperty动作元素</h1>
<hr>
<!-- 根据表单自动匹配所有的属性 -->
<%-- <jsp:setProperty property="*" name="myUsers"/>
用户名:<%=myUsers.getUsername() %><br>
密码:<%=myUsers.getPassword() %><br>
--%>
<!-- name的值与上面id的值一致;匹配原则是根据表单上的名字匹配,表单中的name(例如username和password)
自动和javaBeans中的属性名字进行一一匹配,如果值相等,会自动调用set方法,然后将表单提交过来的值给javaBeans中的属性赋值 -->
<!-- 根据表单匹配部分属性 -->
<jsp:setProperty name="myUsers" property="username" />
用户名:<%=myUsers.getUsername() %><br>
密码:<%=myUsers.getPassword() %><br>
</body>
</html>
慕瓜9220888
慕粉3291149
相关分类