JSP:使用useBean标准动作
2015-04-26 11:00
411 查看
JSP:使用useBean标准动作
jsp
jsp:useBean
JavaBean
赵振江
JavaBean 是一种J***A语言写成的可重用组件。为写成JavaBean,类必须是具体的和公共的,并且具有无参数的构造器。JavaBean 通过提供符合一致性设计模式的公共方法将内部域暴露成员属性。
描述
编写一个UserJsp.jsp页面向用户显示姓名,页面使用useBean标准动作。要求同时使用setProperty动作将用户姓名设置为anne。getProperty动作用于获取anne的名字 。UserJsp.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <jsp:useBean class="bean.User" id="p"> <jsp:setProperty property="name" name="p" value="anne"/> </jsp:useBean> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'UserJsp.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> <jsp:getProperty property="name" name="p"/> </body> </html>
User.java
package bean; public class User { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } }
一张图片说明过程
相关文章推荐
- jsp 指令 标准标签库 动作 的使用
- JSP提供的标准动作
- JSP---JavaBean的使用-jsp:useBean标签相关
- JSP之使用useBean、setProperty、getProperty指令
- JSP 标准标签库(JSTL)与java代码段<%%>与js结合使用
- jsp标准动作
- JSP标准动作
- [JSP]标准标签、<jsp:include、forward、param、useBean、setProperty、getProperty>
- Struts2 JSP的标准动作<jsp:forward>无法访问Action
- JSP 标准动作
- jsp笔记整理(servlet&jstl&el&jsp标准动作)
- JSP中的标准动作[一]
- JavaBean的动作元素、JavaBean四个作用域范围、jsp:useBean、jsp:setProperty、jsp:getProperty
- web笔记九:jsp脚本、jsp标准动作、EL表达式、JSTL标签
- jsp标准动作
- JSP学习笔记(四)-----JSP动作的使用
- Jsp setProperty 和getProperty 动作的使用方法
- Jsp:useBean使用详解
- JSP标准动作
- JSP标准标签(动作)