useBean动作元素
来源:互联网 发布:小黄鸡软件下载 编辑:程序博客网 时间:2024/06/07 20:13
一 <jsp:useBeans>
作用:在jsp页面中实例化或者在指定范围内使用javabean:
<jsp:useBean id="标示符" class="java类全名" scope="作用范围">
二 代码
1、Users.java
package com.po;
/*
* 用户类
* */
public class Users {
private String username;//用户名
private String password;//密码
//保留此默认的构造方法
public Users()
{
}
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;
}
}
2、useBean.jsp
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8"%>
<%
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 'index.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:useBean id="myUsers" class="com.po.Users" scope="page"/>
<h1>使用useBean动作创建javabean的实例</h1>
<hr>
用户名:<%=myUsers.getUsername() %><br>
密码:<%=myUsers.getPassword() %><br>
</body>
</html>
三 测试
阅读全文
0 0
- useBean动作元素
- JSP动作元素useBean语法
- Javabean的useBean,setProperty,getProperty动作元素-学习笔记
- JSP动作元素jsp:useBean,jsp:setProperty,jsp:getProperty
- JSP 之useBean动作
- JavaBean的动作元素、JavaBean四个作用域范围、jsp:useBean、jsp:setProperty、jsp:getProperty
- <jsp:usebean>动作
- JSP:使用useBean标准动作
- JSP_7th_动作指令jsp:useBean
- JSP动作标签useBean--<jsp:useBean> 创建一个对象
- <jsp:useBean />及相关动作深入理解
- jsp中的useBean动作和EL表达式
- JSP动作useBean找不到类错误
- JSP动作标识之 include,forward,useBean
- 动作元素
- jsp useBean元素使用全解
- <jsp:useBean>元素使用全解
- useBean
- traceroute命令应用
- hping命令介绍
- 关于提交AJAX请求后成功,不执行success去执行error的原因及分析
- 路由扫描介绍
- 使用普通方式创建JavaBean
- useBean动作元素
- 批量主机服务扫描
- ncat使用介绍
- linux常用命令
- mtr简介
- 防攻击介绍
- JSP的setProperty
- Matchsticks to Square问题及解法
- JSP的getProperty