JSP-Servlet实现网上BBS项目小案例
来源:互联网 发布:css源码 编辑:程序博客网 时间:2024/04/30 05:44
项目功能:实现一般bbs论坛项目的功能,发表说说 其他好友可以评论
一、数据库的创建:
sql语句如下:
create table `bbs`.`user`( `userid` INT not null auto_increment, `username` CHAR(20) not null, `userpassword` CHAR(20) not null, primary key (`userid`) ); create unique index `PRIMARY` on `bbs`.`user`(`userid`);
create table `bbs`.`article`( `articleid` INT not null auto_increment, `title` CHAR(50) not null, `context` CHAR(200) not null, `articletime` TIME not null, `userid` INT not null, primary key (`articleid`) ); alter table `bbs`.`article` add index `article_user_fk`(`userid`), add constraint `article_user_fk` foreign key (`userid`) references `bbs`.`user`(`userid`); create unique index `PRIMARY` on `bbs`.`article`(`articleid`); create index `article_user_fk` on `bbs`.`article`(`userid`);
create table `bbs`.`comment`( `commentid` INT not null auto_increment, `commenttext` CHAR(200) not null, `commenttime` TIME not null, `userid` INT not null, `articleid` INT not null, primary key (`commentid`) ); alter table `bbs`.`comment` add index `comment_article_fk`(`articleid`), add constraint `comment_article_fk` foreign key (`articleid`) references `bbs`.`article`(`articleid`); alter table `bbs`.`comment` add index `comment_user_fk`(`userid`), add constraint `comment_user_fk` foreign key (`userid`) references `bbs`.`user`(`userid`); create unique index `PRIMARY` on `bbs`.`comment`(`commentid`); create index `comment_user_fk` on `bbs`.`comment`(`userid`); create index `comment_article_fk` on `bbs`.`comment`(`articleid`);
二、项目代码如下:
代码的主要实现:解决中文乱码的问题:
public class MyFilter implements Filter { private String encoding=null; public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException { arg0.setCharacterEncoding(encoding); arg2.doFilter(arg0, arg1); } public void init(FilterConfig arg0) throws ServletException { encoding = arg0.getInitParameter("encoding"); //获得配置文件中的encoding } public void destroy() { }}
在web.xml文件中配置
<!-- 过滤中文乱码的问题 --> <filter> <filter-name>MyFilter</filter-name> <filter-class>com.xuliugen.util.MyFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>MyFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
全部代码在这里:http://download.csdn.net/detail/u010870518/8570147
4 0
- JSP-Servlet实现网上BBS项目小案例
- servlet+jsp+ajax+json实现传递数据小案例
- bbs论坛小项目
- Servlet 实现访问量的统计小案例
- jsp+servlet+javabean 实现的简单网上购物车
- 使用servlet/jsp + mysql 完成的一个bbs练习项目 记录下来
- BBS小项目知识点总结
- BBS系统(jsp + servlet+dwr)
- BBS论坛留言板servlet+jsp+jdbc+mysql
- 基于jsp的bbs论坛-(6)java中对servlet的实现
- 基于jsp的bbs论坛-(6)java中对servlet的实现
- 基于jsp的bbs论坛-(6)java中对servlet的实现
- JSP+Servlet实现文件上传及下载案例
- jsp课程(7)---jsp+servlet+javabean 实现的简单网上购物车
- 案例:如何实现网上考试?
- [简易的网上书店]基于servlet+jsp+mysql一项目搭建
- Jsp+servlet 验证码案例
- Jsp+Servlet+Mysql测试案例
- Eclipse中设置JVM使用内存大小
- [Cocos2d塔防游戏开发]Cocos2dx-3.X完成塔防游戏《王国保卫战》--地图(二)
- git冲突解决
- 2.2
- Xcode----Debugging
- JSP-Servlet实现网上BBS项目小案例
- MM模块-打开前面物料账期的方法
- eclipse无法识别手机设备(本人是小米3)
- 漫谈程序员系列:神奇的四步编程法
- 2.3
- 人的一生要疯狂一次,无论是为一个人,一段情,或一个梦想
- unity3d 关于断点下载和整个下载(用于更新)
- 2.4
- C学习if条件判断和for循环