IDEA+Java+Servlet(1),分布式系统的一致性级别划分
针对最近很多人都在面试,我这边也整理了相当多的面试专题资料,也有其他大厂的面经。希望可以帮助到大家。下面的面试题答案都整理成文档笔记。也还整理了一些面试资料&最新2021收集的一些大厂的面试真题(都整理成文档,小部分截图)最新整理电子书ng实现学生成绩管理系统]( )Java+Swing实现学校教材管理系统Java+Swing实现学校教务管理系统Java+Swing实现企业人事管理系统Java+S
public class NewsCanclePublish extends HttpServlet {
private static final long serialVersionUID = 1L;
NewsService service = new NewsService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String newsID = request.getParameter(“newsID”);
//更新状态为3
String sql = “update news set status=3 where newsID=?”;
service.cd.executeUpdate(sql, new Object[]{Long.parseLong(newsID)});
request.getServletContext().getRequestDispatcher(“/admin/NewsServlet”).forward(request, response);
}
}
NewsDelete
package com.cqut.recruitPortal.servlet;
import com.cqut.recruitPortal.service.NewsService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
- Servlet implementation class NewsDelete
*/
public class NewsDelete extends HttpServlet {
private static final long serialVersionUID = 1L;
NewsService service = new NewsService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String newsID = request.getParameter(“newsID”);
//删除
String sql = “delete from news where newsID=?”;
service.cd.executeUpdate(sql, new Object[]{Long.parseLong(newsID)});
request.getServletContext().getRequestDispatcher(“/admin/NewsServlet”).forward(request, response);
}
}
NewsDetail
package com.cqut.recruitPortal.servlet;
import com.cqut.recruitPortal.service.NewsService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class NewsDetail extends HttpServlet {
private static final long serialVersionUID = 1L;
NewsService service = new NewsService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String newsID = request.getParameter(“newsID”);
//查询给定ID的 新闻
String sql = "select n.newsID AS newsID, " +
"n.title AS title, " +
"n.publishTime AS publishTime, " +
"n.deadLine AS deadLine, " +
"n.count AS count, " +
"n.operator AS operator, " +
"n.type AS type, " +
"nt.name
AS typeName, " +
"o.name
AS operatorName, " +
"n.content
AS content, " +
"n.status
AS status " +
"from news n LEFT JOIN newstype AS nt ON n.type = nt.newsTypeID " +
“LEFT JOIN operator AS o ON o.operatorID = n.operator where newsID=?”;
List<Map<String, Object>> listMap = service.cd.executeQuery(sql, new Object[]{Long.parseLong(newsID)});
if (listMap.size() == 1) {
Map<String, Object> news = listMap.get(0);
if (news.get(“publishTime”) != null) {
news.put(“publishTime”, SysUtil.formatDate((Date) news.get(“publishTime”)));
}
if (news.get(“deadLine”) != null) {
news.put(“deadLine”, SysUtil.formatDate((Date) news.get(“deadLine”)));
}
//为了在jsp页面上有格式我们需要做一定的处理
String content = news.get(“content”).toString();
content = content.replaceAll(" ", " ");
content = content.replaceAll(“\t”, " ");
content = content.replaceAll(“\r\n”, “
”);
news.put(“content”, content);
request.setAttribute(“news”, news);
}
request.getServletContext().getRequestDispatcher(“/admin/newsDetail.jsp”).forward(request, response);
}
}
NewsEdit
package com.cqut.recruitPortal.servlet;
import com.cqut.recruitPortal.entity.Operator;
import com.cqut.recruitPortal.service.NewsService;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
- Servlet implementation class NewsEdit
*/
public class NewsEdit extends HttpServlet {
private static final long serialVersionUID = 1L;
NewsService service = new NewsService();
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request, response);
}
/**
- @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
boolean isOK = true;
String newsID = request.getParameter(“newsID”);
String title = request.getParameter(“title”);
String titleMessage = “”;
if (title == null || title.equals(“”)) {
isOK = false;
titleMessage = “标题不能为空”;
}
String content = request.getParameter(“content”);
String contentMessage = “”;
if (content == null || content.equals(“”)) {
isOK = false;
contentMessage = “内容不能为空”;
}
String type = request.getParameter(“type”);
String typeMessage = “”;
if (type == null || type.equals(“”)) {
typeMessage = “请选择”;
}
Long operatorID = ((Operator) request.getSession().getAttribute(“loginOperator”)).getOperatorID();
Date publishTime = new Date();
Date deadLineTime = null;
String deadLine = request.getParameter(“deadLine”);
String deadLineMessage = “”;
if (deadLine != null && !deadLine.equals(“”)) {
try {
deadLineTime = SysUtil.praseDate(deadLine);
if (deadLineTime.getTime() < publishTime.getTime()) {
isOK = false;
deadLineMessage = “截至时间不能小于当前时间”;
}
} catch (ParseException e) {
isOK = false;
deadLineMessage = “截至时间格式不正确,应为:2014-01-14 22:51:10”;
e.printStackTrace();
}
}
String addMessage = “”;
if (isOK) {
String updateSql = “update news set title
=?, content
=?, type
=?, deadLine
=? where newsID=?”;
Object objs[] = {title, content, Long.parseLong(type), deadLineTime, Long.parseLong(newsID)};
int updateCount = service.cd.executeUpdate(updateSql, objs);
if (updateCount != 1) {
addMessage = “编辑失败”;
} else {
request.getServletContext().getRequestDispatcher(“/admin/NewsServlet”).forward(request, response);
return;
}
}
request.setAttribute(“titleMessage”, titleMessage);
request.setAttribute(“contentMessage”, contentMessage);
request.setAttribute(“deadLineMessage”, deadLineMessage);
request.setAttribute(“typeMessage”, typeMessage);
request.setAttribute(“addMessage”, addMessage);
Map<String, Object> map = new HashMap<String, Object>();
map.put(“title”, title);
map.put(“content”, content);
map.put(“deadLine”, deadLine);
map.put(“newsID”, newsID);
request.setAttribute(“news”, map);
//request.setAttribute(“title”, title);
String phtml = service.createOperationPermissionHtml(type, operatorID);
request.setAttribute(“phtml”, phtml);
request.getServletContext().getRequestDispatcher(“/admin/newsEdit.jsp”).forward(request, response);
}
}
index.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8” pageEncoding=“UTF-8” %>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c” %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + “😕/” + request.getServerName() + “:” + request.getServerPort() + path + “/”;
%>

欢迎 ${loginOperator.name}          
<c:if test=“${loginOperator.type==1}”>
</c:if>
<c:if test=“${loginOperator.type==2}”>
</c:if>
style=“margin: 0px auto; height: 100%; -ms-overflow-x: hidden;”>
login.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8” pageEncoding=“UTF-8” %>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c” %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + “😕/” + request.getServerName() + “:” + request.getServerPort() + path + “/”;
%>
管理员登录
<input type=“text” name=“account”
value=“${account}” id=“accountField”/>
${accountMessage}
<input type=“password” name=“password”
id=“passwordField”/> <font
color=“red”>${passwordMessage}
<input type=“submit”
value=“登录”/>
newsList.jsp
<%@ page language=“java” contentType=“text/html; charset=UTF-8” pageEncoding=“UTF-8” %>
<%@ taglib uri=“http://java.sun.com/jsp/jstl/core” prefix=“c” %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + “😕/” + request.getServerName() + “:” + request.getServerPort() + path + “/”;
%>
当前位置:新闻管理
新闻标题:
<c:forEach items=“${list}” var=“item”>
${item.title} ${item.typeName} ${item.publishTime} ${item.deadLine } ${item.operatorName} ${item.count} ${item.status} ${item.operate}</c:forEach>
<c:if test=“${not empty paginationHtml}”>
</c:if>
四、其他
====
1.其他系统实现
1.JavaWeb系统系列实现
Java+SSH+Bootstrap实现在线考试系统(含论文)
Java+Springboot+Mybatis+Bootstrap+Maven实现网上商城系统
2.JavaSwing系统系列实现
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Java)
最后
针对最近很多人都在面试,我这边也整理了相当多的面试专题资料,也有其他大厂的面经。希望可以帮助到大家。
下面的面试题答案都整理成文档笔记。也还整理了一些面试资料&最新2021收集的一些大厂的面试真题(都整理成文档,小部分截图)
最新整理电子书
ng实现学生成绩管理系统]( )
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-hpmNXDcR-1711637202592)]
[外链图片转存中…(img-BTXmulIO-1711637202593)]
[外链图片转存中…(img-SRMNqLd4-1711637202593)]
[外链图片转存中…(img-jjgUSCHL-1711637202593)]
[外链图片转存中…(img-BvrxAjL9-1711637202593)]
[外链图片转存中…(img-uTGcmXF7-1711637202594)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V获取:vip1024b (备注Java)
[外链图片转存中…(img-YRNxRx3y-1711637202594)]
最后
针对最近很多人都在面试,我这边也整理了相当多的面试专题资料,也有其他大厂的面经。希望可以帮助到大家。
下面的面试题答案都整理成文档笔记。也还整理了一些面试资料&最新2021收集的一些大厂的面试真题(都整理成文档,小部分截图)
[外链图片转存中…(img-K2eEIgeG-1711637202595)]
最新整理电子书
[外链图片转存中…(img-hrqRPWLL-1711637202595)]
更多推荐
所有评论(0)