package com.blog.Servlet;
import com.blog.Entry.Category;
import com.blog.Service.BlogService;
import com.blog.Entry.Blog;
import com.blog.Service.CategoryService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@WebServlet("/BlogServlet")
public class BlogServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doPost(req, resp);
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String action = req.getParameter("action");
System.out.println(action);
switch (action) {
case "add":
add(req, resp);
break;
case "upd":
update(req, resp);
break;
case "del":
delete(req, resp);
break;
case "list":
getBlogFenYe(req, resp);
break;
case "title":
getBlogByBlogTitle(req, resp);
break;
case "read":
getBlogByBlogReadCount(req, resp);
break;
case "date":
getBlogByBlogDate(req, resp);
break;
case "datelist":
getBlogByBlogDateList(req, resp);
break;
case "id":
getBlogById(req, resp);
break;
case "categoryid":
getBlogByCategoryId(req, resp);
break;
default:
break;
}
}
protected void add(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.addHeader("Access-Control-Allow-Origin", "*");
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = resp.getWriter();
// String jsonp = req.getParameter("jsonCallback");
BlogService blogService = new BlogService();
String title = req.getParameter("title");
String time = req.getParameter("time");
String summary = req.getParameter("summary");
String imgUrl = req.getParameter("imgUrl");
String content = req.getParameter("content");
String categoryId = req.getParameter("categoryId");
Blog blog = new Blog();
blog.setBlogTitle(title);
blog.setBlogDateTime(time);
blog.setBlogSummary(summary);
blog.setBlogContent(content);
blog.setBlogImgUrl(imgUrl);
blog.setCategoryId(Integer.parseInt(categoryId));
boolean b = blogService.add(blog);
if (b) {
// out.println(jsonp + "({\"code\":\"200\",\"message\":\"添加成功\",\"errors\":\"0\"})");
out.println("{\"code\":\"200\",\"message\":\"添加成功\",\"errors\":\"0\"}");
} else {
// out.println(jsonp + "({\"code\":\"700\",\"message\":\"服务器不在状态,请稍后再试...\",\"errors\":\"1\"})");
out.println("{\"code\":\"700\",\"message\":\"服务器不在状态,请稍后再试...\",\"errors\":\"1\"}");
}
}
protected void delete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = resp.getWriter();
String jsonp = req.getParameter("jsonCallback");
BlogService blogService = new BlogService();
String blogId = req.getParameter("blogId");
boolean b = blogService.delete(blogId);
if (b) {
out.println(jsonp + "({\"code\":\"200\",\"message\":\"删除成功\",\"errors\":\"0\"})");
} else {
out.println(jsonp + "({\"code\":\"700\",\"message\":\"服务器不在状态,请稍后再试...\",\"errors\":\"1\"})");
}
}
protected void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.addHeader("Access-Control-Allow-Origin", "*");
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = resp.getWriter();
// String jsonp = req.getParameter("jsonCallback");
BlogService blogService = new BlogService();
int blogId = Integer.parseInt(req.getParameter("blogid"));
String title = req.getParameter("title");
String time = req.getParameter("time");
String summary = req.getParameter("summary");
String categoryId = req.getParameter("categoryId");
String content = req.getParameter("content");
String imgUrl = req.getParameter("imgUrl");
Blog blog = new Blog();
blog.setBlogId(blogId);
blog.setBlogTitle(title);
blog.setBlogDateTime(time);
blog.setBlogSummary(summary);
blog.setBlogContent(content);
blog.setBlogImgUrl(imgUrl);
blog.setCategoryId(Integer.parseInt(categoryId));
boolean b = blogService.update(blog);
if (b) {
// out.println(jsonp + "({\"code\":\"200\",\"message\":\"更新成功\",\"errors\":\"0\"})");
out.println("{\"code\":\"200\",\"message\":\"更新成功\",\"errors\":\"0\"}");
} else {
// out.println(jsonp + "({\"code\":\"700\",\"message\":\"服务器不在状态,请稍后再试...\",\"errors\":\"1\"})");
out.println("{\"code\":\"700\",\"message\":\"服务器不在状态,请稍后再试...\",\"errors\":\"1\"}");
}
}
protected void getAllBlog(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
}
protected void getBlogById(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = resp.getWriter();
String jsonp = req.getParameter("jsonCallback");
BlogService blogService = new BlogService();
String blogId = req.getParameter("blogid");
Blog blog = blogService.getBlogById(blogId);
CategoryService categoryService=new CategoryService();
Category category = categoryService.getCategoryById(blog.getCategoryId());
StringBuffer buffer = new StringBuffer();
buffer.append("{");
buffer.append("\"blogId\":\"" + blog.getBlogId() + "\",");
buffer.append("\"blogTitle\":\"" + blog.getBlogTitle() + "\",");
buffer.append("\"blogImgUrl\":\"" + blog.getBlogImgUrl() + "\",");
buffer.append("\"blogDateTime\":\"" + blog.getBlogDateTime() + "\",");
buffer.append("\"blogSummary\":\"" + blog.getBlogSummary() + "\",");
buffer.append("\"blogContent\":\"" + blog.getBlogContent() + "\",");
buffer.append("\"blogReadCount\":\"" + blog.getBlogReadCount() + "\",");
buffer.append("\"commentNum\":\"" + blog.getCommentNum() + "\",");
buffer.append("\"categoryId\":\"" + blog.getCategoryId() + "\",");
buffer.append("\"categoryName\":\"" + category.getCategoryName() + "\",");
buffer.append("\"categoryContent\":\"" + category.getCategoryContent() + "\",");
buffer.append("\"blogNum\":\"" + category.getBlogNum() + "\"");
buffer.append("}");
out.print(jsonp + "(" + buffer + ")");
}
protected void getBlogByCategoryId(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = resp.getWriter();
String jsonp = req.getParameter("jsonCallback");
BlogService blogService = new BlogService();
String categoryId = req.getParameter("categoryid")
没有合适的资源?快使用搜索试试~ 我知道了~
基于JavaScript及多语言实现的前后端分离个人博客管理系统设计源码
共633个文件
js:229个
png:69个
class:66个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 59 浏览量
2024-10-02
14:32:03
上传
评论
收藏 49.19MB ZIP 举报
温馨提示
该项目是一款基于JavaScript及多语言开发的前后端分离个人博客管理系统,源码包含637个文件,涵盖229个JavaScript脚本、69个PNG图片、66个CSS样式、61个JPG图片、48个HTML页面、42个CSS样式文件、32个Java类、30个GIF图片、12个JAR包、9个Markdown文档。系统采用Ajax和Servlet实现前后端数据交互,支持多语言环境。
资源推荐
资源详情
资源评论
收起资源包目录
基于JavaScript及多语言实现的前后端分离个人博客管理系统设计源码 (633个子文件)
BlogServlet.class 12KB
BlogServlet.class 12KB
CommentServlet.class 9KB
CommentServlet.class 9KB
BlogDaoImpl.class 9KB
BlogDaoImpl.class 9KB
UserServlet.class 8KB
UserServlet.class 8KB
CategoryServlet.class 7KB
CategoryServlet.class 7KB
CommentDaoImpl.class 6KB
CommentDaoImpl.class 6KB
UserDaoImpl.class 5KB
UserDaoImpl.class 5KB
CategoryDaoImpl.class 4KB
CategoryDaoImpl.class 4KB
LuanmaFilter$MyRequest.class 3KB
LuanmaFilter$MyRequest.class 3KB
Comment.class 3KB
Comment.class 3KB
CommentFilter.class 3KB
CommentFilter.class 3KB
Blog.class 3KB
Blog.class 3KB
BlogService.class 3KB
BlogService.class 3KB
DataBase.class 2KB
DataBase.class 2KB
MyServletContextListener.class 2KB
MyServletContextListener.class 2KB
OnlineServlet.class 2KB
OnlineServlet.class 2KB
UserService.class 2KB
UserService.class 2KB
Sha256.class 2KB
Sha256.class 2KB
User.class 2KB
User.class 2KB
LuanmaFilter.class 2KB
LuanmaFilter.class 2KB
CommentService.class 2KB
CommentService.class 2KB
Category.class 1KB
Category.class 1KB
CategoryService.class 1KB
CategoryService.class 1KB
MinganciDaoImpl.class 1KB
MinganciDaoImpl.class 1KB
OnlineListener.class 1KB
OnlineListener.class 1KB
BlogDao.class 961B
BlogDao.class 961B
Minganci.class 860B
Minganci.class 860B
MinganciService.class 621B
MinganciService.class 621B
UserDao.class 582B
UserDao.class 582B
CommentDao.class 565B
CommentDao.class 565B
CountUtils.class 557B
CountUtils.class 557B
CategoryDao.class 526B
CategoryDao.class 526B
MinganciDao.class 215B
MinganciDao.class 215B
amazeui.min.css 249KB
blog-common.min.css 59KB
icono.min.css 48KB
editor_ie7.css 47KB
app.css 47KB
editor_iequirks.css 46KB
editor_ie8.css 46KB
editor_ie.css 45KB
editor_gecko.css 45KB
editor.css 44KB
custom.css 40KB
font-awesome.min.css 30KB
font-awesome.min.css 30KB
jBox.all.css 20KB
dialog_ie7.css 17KB
dialog_ie8.css 16KB
dialog_iequirks.css 16KB
dialog_ie.css 16KB
dialog_opera.css 16KB
dialog.css 15KB
fullcalendar.min.css 15KB
Demo1.css 12KB
amazeui.datatables.min.css 9KB
css.css 8KB
style.css 7KB
font_1699298_er2ddxbdu7s.css 6KB
fullcalendar.print.css 5KB
demo.css 5KB
admin.css 5KB
Playground.Login.css 5KB
sample.css 5KB
all1.css 3KB
normalize.min.css 2KB
page.css 2KB
共 633 条
- 1
- 2
- 3
- 4
- 5
- 6
- 7
资源评论
lsx202406
- 粉丝: 2448
- 资源: 5591
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- (源码)基于SimPy和贝叶斯优化的流程仿真系统.zip
- (源码)基于Java Web的个人信息管理系统.zip
- (源码)基于C++和OTL4的PostgreSQL数据库连接系统.zip
- (源码)基于ESP32和AWS IoT Core的室内温湿度监测系统.zip
- (源码)基于Arduino的I2C协议交通灯模拟系统.zip
- coco.names 文件
- (源码)基于Spring Boot和Vue的房屋租赁管理系统.zip
- (源码)基于Android的饭店点菜系统.zip
- (源码)基于Android平台的权限管理系统.zip
- (源码)基于CC++和wxWidgets框架的LEGO模型火车控制系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功