Web基础-JavaWeb:Eclipse下基于Servlet+JSP的论坛模板

资源

GayHub:无名的基于JSP和Servlet的论坛模板

环境

CentOS 7
MySQL 5.7
Tomcat 7
jdk 1.8

食用方法

建议自己建工程,然后把文件复制进去
不建议直接导入
出于安全性考虑
所有可能泄露个人隐私(如我的用户目录路径、数据库密码等)的相关配置已被删除
可能会导致许多问题
在这里插入图片描述

修改MySQL默认编码

CentOS 7修改MySQL默认编码
顺便记一下MySQL 5.0版本以上VARCHAR(50)就是可以放50个汉字

建库

create database wumingBBS

建用户

出于安全性考虑
设置一个新用户UserName只能在localhost上登录

create user 'UserName'@'localhost' identified by 'password';
grant select,insert,update,delete on wumingBBS.* to UserName@localhost;

建表

用户信息表(邮箱,用户名_主键,密码,账号状态)

create table emailuserpass(
emailAddress varchar(40) not null,
userName varchar(40) primary key not null,
password varchar(40) not null,
Available boolean not null
)engine=innodb default charset=utf8 collate=utf8_general_ci;

管理员信息表(邮箱,管理员名_主键,密码)

create table admin(
emailAddress varchar(40) not null,
adminName varchar(40) primary key not null,
password varchar(40) not null
)engine=innodb default charset=utf8 collate=utf8_general_ci;

帖子表(贴id_主键_自增,用户名_外键,贴信息,发帖时间)

create table post(
postID int(4) primary key auto_increment,
userName varchar(40) not null,
postInfo varchar(200) not null,
postDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
foreign key (userName) references emailuserpass(userName) on delete cascade
)engine=innodb default charset=utf8 collate=utf8_general_ci;

评论表

create table postcomment(
commentID int(4) primary key auto_increment,
postID int(4),
userName varchar(40) not null,
commentInfo varchar(200) not null,
commentDate TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
foreign key (postID) references post(postID) on delete cascade on update cascade,
foreign key (userName) references emailuserpass(userName) on delete cascade
)engine=innodb default charset=utf8 collate=utf8_general_ci;

ER图
在这里插入图片描述

三层结构与MVC

在这里插入图片描述

工程结构

在这里插入图片描述

Java Resources详解

在这里插入图片描述

  1. dbcp

对外提供数据库连接池接口的包
其下ConnectionPool主要方法有:提供连接池实例、提供连接实例、释放连接

  1. myfilter

过滤器包
其下三个Filter分别对AdminShowAll.jsp、AdminView.jsp、UserView.jsp进行访问控制
防止越权查看信息

  1. myjavabean

javabean包
其下四个bean分别对应数据库中四张表

  1. myservlet

其下五个Servlet分别用于处理
管理员登录及删封、对某条帖子的评论、用户发帖、游客查看帖子、用户注册及登录
的相关请求

  1. mysql

数据访问层(注意:由于欠考虑所以我这层分的不是很清楚)
实际应该再细分一层
其下的Java代码分别用于对外提供
管理员登录
评论增删查
帖子增删查
用户注册 登录 封禁 查看
的相关方法

发布了61 篇原创文章 · 获赞 11 · 访问量 4881

猜你喜欢

转载自blog.csdn.net/weixin_43249758/article/details/102866208