I. JavaBeans design principles
There is a User.java class
/** User Class*/Package Com.po; Public classuser{PrivateString username; PrivateString password; PublicUser () {} PublicString GetUserName () {returnusername; } Public voidSetusername (String username) { This. Username =username; } PublicString GetPassword () {returnpassword; } Public voidSetPassword (String password) { This. Password =password; } }
View Code
Traditional methods of development:
//Introducing Class<%@ page import="Com.po.User"%>//instantiation of<%User User=NewUser (); User.setusername ("Amdin"); User.setpassword ("123");%>//Get<div> Username: <%=user.getusername ()%></div><div> Password: <%=user.getpassword ()%></div >
Two .<jsp:usebean>
// Use the action Usebean<jsp:usebean id="user"class=" Com.po.User" /><div> user name: <%=user.getusername ()%></div><div> Password: <%= User.getpassword ()%></div>
"Javaweb" study notes six JavaBeans