标签:
一.JavaBeans 设计原则
有一个User.java类
/* * 用户类 */ package com.po; public class User{ private String username; private String password; public User(){ } 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; } }
传统的开发方法:
//引入class <%@ page import="com.po.User" %> //实例化 <% User user = new User(); user.setUsername("amdin"); user.setPassword("123"); %> //获取 <div>用户名:<%=user.getUsername() %></div> <div>密码:<%=user.getPassword() %></div>
二.<jsp:useBean>
//使用动作useBean <jsp:useBean id="user" class="com.po.User" /> <div>用户名:<%=user.getUsername() %></div> <div>密码:<%=user.getPassword() %></div>
标签:
原文地址:http://www.cnblogs.com/dtdxrk/p/4693923.html