Record learning every day, have a good mood every day. * ^ _ ^ *
When learning dynamic website design and production projects, to facilitate future access to timely, record it in this platform in the development process of the project. In the study, when the selection of the SSM (MYECLIPSE), whether this framework is to learn or use are very convenient, simple and approachable. Is a framework that we can focus on learning to learn programming, I chose MYECLIPSE in development of dynamic Web site design and production project to build when SSM (MYECLIPSE) framework, will eventually dynamic website design and production project development project for a background.
The project has a user role includes user, each role contains its own user name and password.
There is any relationship between the users in the system, we will save their relationship in the message table. Their relationship is mingzi field corresponds to such a message the user and the user, id user id field corresponds to the user's mail.
The summary results of all system data: administrator (admin), article (wenzhang), message (liuyan), user (yonghu)
Administrators table
Field Name | Type | property | describe the above mentioned id | INT ( 11 ) | PRIMARY KEY | administrator the above mentioned id username | VARCHAR ( 255 ) | | account password | VARCHAR ( 255 ) | | password
Article table
Field Name | Type | property | describe the above mentioned id | INT ( 11 ) | PRIMARY KEY | article the above mentioned id biaoti | VARCHAR ( 255 ) | | title neirong | VARCHAR ( 255 ) | | Content fabushijian | VARCHAR ( 255 ) | | Published
Comment Form
Field Name | Type | property | describe the above mentioned id | INT ( 11 ) | PRIMARY KEY | Feedback the above mentioned id neirong | VARCHAR ( 255 ) | | Content liuyanshijian | VARCHAR ( 255 ) | | Posted at yonghu | VARCHAR ( 255 ) | | User yonghuid | VARCHAR ( 255 ) | | User id
user table
Field Name | Type | property | describe the above mentioned id | INT ( 11 ) | PRIMARY KEY | user the above mentioned id mingzi | VARCHAR ( 255 ) | | name username | VARCHAR ( 255 ) | | account password | VARCHAR ( 255 ) | | password
SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- -- ---------------------------- -- Table structure for ggdongtaisheji -- ---------------------------- DROP TABLE IF EXISTS `t_admin`; CREATE TABLE `t_admin` (`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '管理员id',`username` VARCHAR(255) DEFAULT NULL COMMENT '账号',`password` VARCHAR(255) DEFAULT NULL COMMENT '密码',PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='管理员'; -- ---------------------------- DROP TABLE IF EXISTS `t_wenzhang`; CREATE TABLE `t_wenzhang` (`id` INT(11) NOT NULL AUTO_INCREMENT COMMENT '文章id' , `Biaoti` VARCHAR ( 255 ) the DEFAULT NULL the COMMENT ' title ' ,` neirong` VARCHAR ( 255 ) the DEFAULT NULL the COMMENT ' content ' , `fabushijian` VARCHAR ( 255 ) the DEFAULT NULL the COMMENT ' Published ' , PRIMARY KEY (` the above mentioned id `) ) ENGINE = MyISAM the DEFAULT CHARSET = utf8 the COMMENT = ' article '; - ---------------------------- the DROP TABLE the IF EXISTS `t_liuyan`; the CREATE TABLE ` t_liuyan` ( `id` the INT ( . 11 ) the NOT NULL the AUTO_INCREMENT the cOMMENT ' message ID ' , `neirong` VARCHAR ( 255 ) the DEFAULT NULL the cOMMENT ' content ' ,` liuyanshijian` VARCHAR ( 255 ) the DEFAULT NULL the cOMMENT ' message time ' , `yonghu` VARCHAR (255) DEFAULT NULL COMMENT '用户',`yonghuid` INT(11) DEFAULT NULL COMMENT '用户id',PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='留言'; -- ---------------------------- DROP TABLE IF EXISTS `t_yonghu`; CREATE TABLE `t_yonghu` (`id` INT(. 11 ) the NOT NULL the AUTO_INCREMENT the COMMENT ' user ID ' , `mingzi` VARCHAR ( 255 ) the DEFAULT NULL the COMMENT ' name ' ,` username` VARCHAR ( 255 ) the DEFAULT NULL the COMMENT ' account number ' , `password` VARCHAR ( 255 ) the DEFAULT NULL the COMMENT ' password ' , a PRIMARY KEY ( `id`) ) ENGINE = MyISAMThe DEFAULT the CHARSET = UTF8 the COMMENT = ' user ' ;
Add Article module:
Add articles present in the system function, by clicking the Add article to jump to the function module, the function module, fill in the information corresponding article. After article contains information title, release time, filling out all the information, via the post method to submit data to tianjiawenzhang.action, the address will respond in the server tianjiawenzhangact method wenzhangController in class. In response to a result, all the articles acquired information, encapsulating a wenzhang class, using the insert method wenzhangdao wenzhangController defined in the class, the sentence data is inserted into wenzhang database table. And gives the user prompts, add articles successful, save the information to the message request, this information will be shown on the page. The part of the core code is as follows:
The page article by adding transmission method wenzhangdao insert into the database wenzhangdao.insert (wenzhang);
Add the article successful information stored in the message request, the user is given the page prompt request.setAttribute ( "message", "the article added successfully");
Return to article management interface
return "forward:/tianjiawenzhang.action";
Query Articles module:
In the browser when you enter the query page article, this time the browser address bar is wenzhangguanli.action, the address will respond wenzhangController class wenzhangguanli, in the process, get all the information through articles selectByexample method, and the information save the request, make cycle through the pages. The part of the core code is as follows:
Generating a sample-based articles, query by example defined WenzhangExample example = new WenzhangExample ();
Check out all the information article List wenzhangall = wenzhangdao.selectByExample (example) by selectByExample method of wenzhangdao;
The article information stored in the request, on display request.setAttribute ( "wenzhangall", wenzhangall) page by foreach method;
Return to article management interface
return "forward:/wenzhangguanli.action";
Modify article module:
Click the Edit button, you can jump to the article modification page. In the article modification page, you will initialize all information and correspondence information of the article is filled to the corresponding edit field. After editing the article information page via the post method encapsulates data into a paper entity, passed into wenzhangController in. In xiugaiwenzhang the reception, after reception is completed, the call updateByPrimaryKeySelective method wenzhangMapper modified. The part of the code as follows:
Corresponding modified by modifying the method according wenzhangdao article id wenzhangdao.updateByPrimaryKeySelective (wenzhang);
The modified article success message, save the message request to give the user prompt request.setAttribute in the page ( "message", "modify Article success");
Return to article management interface
return "forward:/wenzhangguanli.action";
Delete articles module:
By a label, shanchuwenzhang the page? Id = id will be passed into the background by shanchuwenzhang receiving the article id. Use of deleteByid
Remove this article, complete the deletion. Delete the definition of a successful message, delete the article success, and saved to the request, the part of the code is as follows:
Delete by deleting the corresponding method according to id wenzhangdao article wenzhangdao.deleteByPrimaryKey (id);
The article will be deleted success information stored in the message request, give the user prompt request.setAttribute in the page ( "message", "delete articles success");
Return to article management interface
return "forward:/wenzhangguanli.action";