3.15课堂笔记
快捷键:
JavaBean的基本实验:
代码
T1:
Student.java
package com.zss.www;
public class Student {
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;
}
}
T2:
My315Jsp02send
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SEND</title>
</head>
<body>
<form id="form1" name="form1" method="get" action="My315Jsp03receiver.jsp">
<p>姓名:
<label>
<input type="text" name="username" id="textfield" />
</label>
</p>
<p>密码:
<label>
<input type="text" name="password" id="textfield2" />
</label>
</p>
<p>
<label>
<input type="submit" name="button" id="button" value="提交" />
</label>
</p>
</form>
</body>
</html>
T3:
My315Jsp03receiver
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<jsp:useBean id="mystudent" scope="page" class="com.zss.www.Student">
</jsp:useBean>
<jsp:setProperty name="mystudent" property="*"/>
<%
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 'receiver.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>
3.15web <br>
<%=mystudent.getUsername() %><br>
<%=mystudent.getPassword() %><br>
</body>
</html>
运行截图: