点赞再看,养成习惯
项目介绍
本项目使用jsp+servlet+mysql架构搭建可聊天的酷炫博客系统。界面非常好看,除了登录注册个人中心修改外,博客还添加背景音乐,可在线交友聊天,发表动态,相互评论等,喜欢的博文还能添加收藏。
开发环境:
- jdk 8
- intellij idea
- tomcat 8
- mysql 5.7
所用技术:
- jsp+servlet
- js+ajax
- layui
- jdbc+C3P0
博客访问地址
http://localhost:8090/indexServlet
运行效果
-
登录
-
首页
- 动态评论
-
关注列表
-
个人资料
- 聊天页面
核心代码:
- 注册使用邮箱验证码
//邮件对象
public class EmailModel {
private String title;//标题
private String receiverEmail;//接收人邮箱
private String text;//发送内容
public static String register="欢迎来到微博客\n您的注册为:";
public static String registerTitle="注册验证码";
public static String findPwdTitle="找回密码:";
public static String findPwdText="找回密码验证码:";
}
// 邮件发送
public class EmailUtils {
private final static String authorizationCode="khdotvxxxxdba"; //授权码-自己设置
private final static String senderEmail ="1022287044@qq.com"; //发送人邮箱--测试邮箱
//发送邮件方法
public static int sendEmail(EmailModel emailModel){
try{
Properties props = new Properties();
// 开启debug调试
props.setProperty("mail.debug", "false");
// 发送服务器需要身份验证
props.setProperty("mail.smtp.auth", "true");
// 设置邮件服务器主机名
props.setProperty("mail.host", "smtp.qq.com");
// 发送邮件协议名称
props.setProperty("mail.transport.protocol", "smtp");
MailSSLSocketFactory sf = new MailSSLSocketFactory();
sf.setTrustAllHosts(true);
props.put("mail.smtp.ssl.enable", "true");
props.put("mail.smtp.ssl.socketFactory", sf);
Session session = Session.getInstance(props);
Message msg = new MimeMessage(session);
msg.setSubject(emailModel.getTitle());//标题
StringBuilder builder = new StringBuilder();
builder.append(emailModel.getText());
msg.setText(