1. 程式人生 > >JavaEE權威讀書筆記(四)JavaBean

JavaEE權威讀書筆記(四)JavaBean

1,bean.Team

package bean;

public class Team {
	private int id;
	private String name;
	private String slogan;
	private String leader;
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSlogan() {
		return slogan;
	}
	public void setSlogan(String slogan) {
		this.slogan = slogan;
	}
	public String getLeader() {
		return leader;
	}
	public void setLeader(String leader) {
		this.leader = leader;
	}
}

addTeam.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<form action="addTeam.jsp" method="post">
		<p>
			姓名:<input type="text" name="name">
		<p>
			口號:<input type="text" name="slogan">
		<p>
			組長:<input type="text" name="leader">
		<p>
			<input type="submit" value="確定"> <input type="reset"
				value="重填">
	</form>
</body>
</html>

addTeam.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>
	<jsp:useBean id="team" class="bean.Team"></jsp:useBean>
	<jsp:setProperty name="team" property="*"></jsp:setProperty>
	<h1 align="center">增加小組</h1>
	<p>
		組名:<jsp:getProperty property="name" name="team" />
	<p>
		口號:<jsp:getProperty property="slogan" name="team" />
	<p>
		組長:<jsp:getProperty property="leader" name="team" />
</body>
</html>