1.1 Struts Bean标签库 Struts Bean标签库中的标签列表
Tag name
Description
cookie
Define a scripting variable based on the value(s) of the specified request cookie.
define
Define a scripting variable based on the value(s) of the specified bean property.
header
Define a scripting variable based on the value(s) of the specified request header.
include
Load the response from a dynamic application request and make it available as a bean.
message
Render an internationalized message string to the response.
page
Expose a specified item from the page context as a bean.
parameter
Define a scripting variable based on the value(s) of the specified request parameter.
resource
Load a web application resource and make it available as a bean.
size
Define a bean containing the number of elements in a Collection or Map.
struts
Expose a named Struts internal configuration object as a bean.
write
Render the value of the specified bean property.
1.2 Struts Template标签库 Struts Template标签库中的标签列表
Tag name
Description
insert
Retrieve (or include) the specified template file, and then insert the specified content into the template's layout. By changing the layout defined in the template file, any other file that inserts the template will automatically use the new layout.
put
Create a request-scope bean that specifies the content to be used by the get tag. Content can be printed directly or included from a JSP or HTML file.
get
Retrieve content from a request-scope bean, for use in the template layout.
1. 示例
示例实现了一个简单的项目信息CRUD(添加、查询、更新、删除)+分页显示的功能。
其中项目有如下属性:
l 项目编号
l 项目名称
l 项目所属区域(区域存在与一个字典表中)
l 项目分成比例(0.00%--100.00%)
数据库结构定义如下所示(采用Oracle8i数据库,如果采用其它数据库请作相应变化):
SITES ——区域表
Name
Datatype
Null Option
Comment
Is PK
SITECODE
VARCHAR2(10)
NOT NULL
区域号
Yes
SITENAME
VARCHAR2(30)
NOT NULL
区域名称
No
PROJECTS ——项目表
Name
Datatype
Null Option
Comment
Is PK
PROJECTCODE
VARCHAR2(10)
NOT NULL
项目编号
Yes
PROJECTNAME
VARCHAR2(30)
NOT NULL
项目名称
No
SITECODE
VARCHAR2(10)
NOT NULL
所属区域号
DISCOUNT
NUMBER
NULL
项目分成比例
附:在ORACLE8i中创建数据表的语句为:
--创建区域表
CREATE TABLE SITES (
SITECODE VARCHAR2(10) NOT NULL,
SITENAME VARCHAR2(30) NOT NULL
);
--添加主键
ALTER TABLE SITES
ADD ( CONSTRAINT SITES_PKSITECODE PRIMARY KEY (SITECODE)
USING INDEX );
--创建项目信息表
CREATE TABLE PROJECTS(
PROJECTCODE VARCHAR2(10) NOT NULL,
PROJECTNAME VARCHAR2(30) NOT NULL,
SITECODE VARCHAR2(10) NOT NULL,
DISCOUNT NUMBER NULL
);
--添加主键索引
ALTER TABLE PROJECTS
ADD ( CONSTRAINT PROJECTS_PKPROJECTCODE PRIMARY KEY (PROJECTCODE)
USING INDEX );
--添加外键索引
CREATE INDEX FK_PROJECTSSITECODE ON PROJECTS
(
SITECODE ASC
);
--添加外键约束
ALTER TABLE PROJECTS
ADD ( CONSTRAINT FK_PROJECTSSITECODE
FOREIGN KEY (SITECODE)
REFERENCES SITES ) ;
本文地址:http://com.8s8s.com/it/it16529.htm