当前位置:首页 > 博客网站的分析与设计
create table db_article(
article_id INT AUTO_INCREMENT PRIMARY KEY, category_id int not null references db_category(category_id), article_title varchar(200) not null, article_content text not null, article_datetime timestamp not null, article_acessNum int not null default 0, article_reviewNum int not null default 0 );
create table db_review(
review_id INT AUTO_INCREMENT PRIMARY KEY, article_id int not null references db_article(article_id), review_content text not null, review_datetime timestamp not null,
user_id int not null references db_user(user_id) );
create table db_picture(
picture_id INT AUTO_INCREMENT PRIMARY KEY, blog_id int not null references db_blog(blog_id), picture_title varchar(50) not null, picture_profile varchar(200) not null,
picture_accessNum int not null default 0 );
五、程序结构设计(文件夹和类包规划)
article(博文),blog(博客),category(博文分类),common (公共),css(样式表),images(图像),picture(相视图层 册),review(评论),script(脚本),upfiles(上传文件),user(用户),rixin.me.blog.tag(自定义标签包) 控制层 rixin.me.blog.action(控制类包) rixin.me.blog.service(业务逻辑实现类包) rixin.me.blog.iservice(业务逻辑接口包) 业务逻辑层 rixin.me.blog.common(一些公共类包) rixin.me.blog.model(数据模型实体类包) rixin.me.blog.dao(数据访问层实现类包) 数据访问层 rixin.me.blog.idao(数据访问层接口包) 数据库 MySQL5.5 六、数据模型设计
1.用户数据模型类User 2.博客数据模型类Blog 3.博文数据模型类Article 4.博文分类数据模型类Category 5.评论数据模型类Review 6.相册数据模型类Picture
(类的定义参见rixin.me.blog.model包)
七、数据访问层接口设计
1.分页集合接口PList
5.博文分类数据访问接口ICategoryDao 6.博文数据访问接口IArticleDao 7.评论数据访问接口IReviewDao 8.相册数据访问接口IPictureDao 详细设计参见rixin.me.blog.idao包
八、业务逻辑层接口设计
1.自定义用户异常类MyException(定义在rixin.me.blog.common包) 2.用户业务逻辑接口IUserService 3.博客业务逻辑接口IBlogService
4.博文分类业务逻辑接口ICategoryService 5.博文业务逻辑接口IArticleService 6.评论业务逻辑接口IReviewService 7.相册业务逻辑接口IPictureService 详细设计参见rixin.me.blog.iservice包
九、页面的整体布局
1.Div分布效果图
2.基本结构网页 3.基本CSS样式表
在css文件夹下建立all.css样式表。 4.优化界面结构
在WEB-INF文件夹下建立三个jsp片段文件top.jspf、sidebar.jspf、footer.jspf定义网站的顶部、左侧栏和底部。在此基础上优化index.jsp首页结构。(参见源代码)
十、数据层设计
1.使用连接池连接数据库
打开myblog项目,在META-INF文件夹下建立context.xml文件。文件内容如下: reloadable=\ crossContext=\> url=\/>
这是为项目配置数据源。
接下来,把mysql-connector-java-5.1.15-bin.jar这个MySQL数据库的Jdbc驱动包放到WEB-INF\\lib目录下。(这个是必须的,发布网站时用)
2.设计访问数据库的辅助类MySQLHelper.java,实现数据库的连接功能和释放资源功能。放到rixin.me.blog.common包。 技术要点:
(1) 采用JNDI技术获得DataSource对象。生成DataSource对象的工厂为
org.apache.commons.dbcp.BasicDataSourceFactory。
(2) 使用javax.naming包中的Context接口,调用lookup方法检索数据源对象。 (3) 通过JNDI查找数据源,本项目的JNDI为java:comp/env/jdbc/db。Tomcat提供的
JNDI必须绑定前缀java:comp/env。
package rixin.me.blog.common;
共分享92篇相关文档