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 下载量 70 浏览量
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
- 粉丝: 2793
- 资源: 5659
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- lanchaoHunanHoutaiQiantai
- (177377030)Python 爬虫.zip
- (177537818)python爬虫基础知识及爬虫实例.zip
- 自动驾驶横纵向耦合控制-复现Apollo横纵向控制 基于动力学误差模型,使用mpc算法,一个控制器同时控制横向和纵向,实现横纵向耦合控制 matlab与simulink联合仿真,纵向控制已经做好油门刹
- (178199432)C++实现STL容器之List
- (178112810)基于ssm+vue餐厅点餐系统.zip
- 两相步进电机FOC矢量控制Simulink仿真模型 1.采用针对两相步进电机的SVPWM控制算法,实现FOC矢量控制,DQ轴解耦控制~ 2.转速电流双闭环控制,电流环采用PI控制,转速环分别采用PI和
- VMware虚拟机USB驱动
- Halcon手眼标定简介(1)
- (175128050)c&c++课程设计-图书管理系统
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功