最后希望可以帮助到大家!
千千万万要记得:多刷题!!多刷题!!
之前算法是我的硬伤,后面硬啃了好长一段时间才补回来,算法才是程序员的灵魂!!!!
篇幅有限,以下只能截图分享部分的资源!!
(1)多线程(这里以多线程为代表,其实整理了一本JAVA核心架构笔记集)
(2)刷的算法题(还有左神的算法笔记)
(3)面经+真题解析+对应的相关笔记(很全面)
(4)视频学习(部分)
ps:当你觉得学不进或者累了的时候,视频是个不错的选择
在这里,最后只一句话:祝大家offer拿到手软!!
}
}
package com.ec.survey.ctrl;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ec.survey.dao.DAOFactory;
import com.ec.survey.dao.QuestionDAO;
import com.ec.survey.dto.Question;
public class QuestionManage extends HttpServlet {
/**
-
The doGet method of the servlet.
-
This method is called when a form has its tag value method equals to get.
-
@param request the request send by the client to the server
-
@param response the response send by the server to the client
-
@throws ServletException if an error occurred
-
@throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
/**
-
The doPost method of the servlet.
-
This method is called when a form has its tag value method equals to post.
-
@param request the request send by the client to the server
-
@param response the response send by the server to the client
-
@throws ServletException if an error occurred
-
@throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String mutex = “”;
String mutex1 = “”;
String mutex2 = “”;
String op=request.getParameter(“op”);
if(“AddQuestion”.equals(op)){
String sid=request.getParameter(“sid”);
String type=request.getParameter(“type”);
String qhead=request.getParameter(“qHead”);
String qbody=request.getParameter(“qBody”);
String qresult=request.getParameter(“qResult”);
String qimg=request.getParameter(“qImg”);
Question question=new Question();
question.setSurvey(Long.valueOf(sid));
question.setQType(Long.valueOf(type));
question.setQHead(qhead);
question.setQBody(qbody);
question.setQResult(qresult);
question.setQImg(qimg);
question.setQOrder(0L);
String [] qbodys=qbody.split(“&\$\$&”);
String spliter=“”;
for(int i=1;i<qbodys.length;i++)
if(i==qbodys.length-1)
spliter=spliter+“null&null”;
else
spliter=spliter+“null&”;
question.setQJdtz(spliter);
QuestionDAO dao=DAOFactory.getQuestionDAO();
boolean ret=dao.addQuestion(question);
if(ret==true)
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=true&sid=”+sid);
else{
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=false”);
}
}else if(“DelQuestion”.equals(op)){
String sid=request.getParameter(“sid”);
String qid=request.getParameter(“qid”);
QuestionDAO dao=DAOFactory.getQuestionDAO();
boolean ret=dao.delQuestion(Long.valueOf(qid));
if(ret==true)
response.sendRedirect(“…/admin/QuestionAdmin.jsp?sid=”+sid);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=false”);
}else if(“EditQuestion”.equals(op)){
String sid=request.getParameter(“sid”);
String qid=request.getParameter(“qid”);
//System.out.println(qid);
String type=request.getParameter(“type”);
String qhead=request.getParameter(“qHead”);
String qbody=request.getParameter(“qBody”);
String qimg=request.getParameter(“qImg”);
QuestionDAO dao=DAOFactory.getQuestionDAO();
synchronized(mutex){
Question question=dao.findQuestion(Long.valueOf(qid));
//System.out.println(question==null);
question.setQType(Long.valueOf(type));
question.setQHead(qhead);
question.setQBody(qbody);
question.setQImg(qimg);
String [] qbodys=qbody.split(“&\$\$&”);
String spliter=“”;
for(int i=1;i<qbodys.length;i++)
if(i==qbodys.length-1)
spliter=spliter+“null&null”;
else
spliter=spliter+“null&”;
question.setQJdtz(spliter);
question.setQOrder(0L);
boolean ret=dao.updateQuestion(question);
if(ret==true)
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=true&sid=”+sid);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=false”);
}
}else if(“setJD”.equals(op)){
String sid=request.getParameter(“sid”);
String qid=request.getParameter(“qid”);
int jd_count=Integer.parseInt(request.getParameter(“jd_count”));
List list=new ArrayList();
for(int j=0;j<jd_count;j++){
String checked=request.getParameter(“check_jd”+j);
list.add(checked);
}
QuestionDAO dao=DAOFactory.getQuestionDAO();
synchronized(mutex1){
Question question=dao.findQuestion(Long.valueOf(qid));
String [] jdtz=question.getQJdtz().split(“&”);
for(int j=0;j<jdtz.length;j++){
if(“on”.equals(list.get(j)))
jdtz[j]=“over”;
}
String newJdtz=“”;
for(int j=0;j<jdtz.length;j++){
if(j==jdtz.length-1)
newJdtz=newJdtz+jdtz[j];
else
newJdtz=newJdtz+jdtz[j]+“&”;
}
question.setQJdtz(newJdtz);
boolean ret=dao.updateQuestion(question);
if(ret==true)
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=true&sid=”+sid);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=false”);
}
}else if(“setTZ”.equals(op)){
String sid=request.getParameter(“sid”);
String qid=request.getParameter(“qid”);
int jd_count=Integer.parseInt(request.getParameter(“tz_count”));
List list=new ArrayList();
for(int j=0;j<jd_count;j++){
String checked=request.getParameter(“check_tz”+j);
list.add(checked);
}
QuestionDAO dao=DAOFactory.getQuestionDAO();
synchronized(mutex2){
Question question=dao.findQuestion(Long.valueOf(qid));
//set value of jdtz for every choice
String [] jdtz=question.getQJdtz().split(“&”);
for(int j=0;j<jdtz.length;j++){
//System.out.println(list.get(j));
if(“on”.equals(list.get(j))||list.get(j)==null){
jdtz[j]=“null”;
}else
jdtz[j]=list.get(j);
}
//start concat the jdtz field with &.
String newJdtz=“”;
for(int j=0;j<jdtz.length;j++){
if(j==jdtz.length-1)
newJdtz=newJdtz+jdtz[j];
else
newJdtz=newJdtz+jdtz[j]+“&”;
}
question.setQJdtz(newJdtz);
boolean ret=dao.updateQuestion(question);
if(ret==true)
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=true&sid=”+sid);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=Question&ret=false”);
}
}
}
}
package com.ec.survey.ctrl;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ec.survey.dao.AnswersheetDAO;
import com.ec.survey.dao.DAOFactory;
import com.ec.survey.dao.QuestionDAO;
import com.ec.survey.dao.SurveyDAO;
import com.ec.survey.dao.TextDAO;
import com.ec.survey.dto.Survey;
public class SurveyManage extends HttpServlet {
/**
*/
private static final long serialVersionUID = -1737458302140188798L;
/**
- Constructor of the object.
*/
public SurveyManage() {
super();
}
/**
- Destruction of the servlet.
*/
public void destroy() {
super.destroy(); // Just puts “destroy” string in log
// Put your code here
}
/**
-
The doGet method of the servlet.
-
This method is called when a form has its tag value method equals to get.
-
@param request the request send by the client to the server
-
@param response the response send by the server to the client
-
@throws ServletException if an error occurred
-
@throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out=response.getWriter();
String mutex1=“”;
String mutex2=“”;
if(“AddSurvey”.equals(request.getParameter(“op”))){
SurveyDAO surveydao=DAOFactory.getSurveyDAO();
Survey survey=new Survey();
survey.setSName(request.getParameter(“Survey_name”));
survey.setSAuthor(request.getParameter(“Survey_author”));
survey.setSDesc(request.getParameter(“Survey_description”));
survey.setSCreateDate(new Date());
SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd”);
try {
survey.setSExpireDate(sdf.parse(request.getParameter(“Survey_ExpireDate”)));
} catch (ParseException e) {
out.println(“wrong DATE format.please check it!”);
}
survey.setTemplet(0L);
survey.setSIpRepeat(Boolean.valueOf(request.getParameter(“Survey_ipRepeat”)));
survey.setSIsOpen(Boolean.valueOf(request.getParameter(“Survey_isOpen”)));
if(request.getParameter(“Survey_isImg”)!=null)
survey.setSImg(request.getParameter(“imgfilepath”));
if(request.getParameter(“Survey_isPassword”)!=null)
survey.setSPassword(request.getParameter(“Survey_Password1”));
if(request.getParameter(“Survry_IPLimit”)!=null){
//survey.setSIpLimitType(request.getParameter(“Survey_ipLimitKinds”));
survey.setSIpRange(request.getParameter(“Survey_ipRange”));
}
survey.setSHits(0L);
survey.setSIsAudited(false);
survey.setSUsehits(0L);
boolean ret=surveydao.addSurvey(survey);
//System.out.println(ret);
if(ret==true)
response.sendRedirect(“…/admin/OpResult.jsp?op=SurveyAdd&ret=true”);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=SurveyAdd&ret=false”);
}
else if(“SurveyAudi”.equals(request.getParameter(“op”))){
Boolean audit=Boolean.valueOf(request.getParameter(“audit”));
SurveyDAO surveydao=DAOFactory.getSurveyDAO();
synchronized(mutex1){
Survey survey=surveydao.findSurvey(Long.valueOf(request.getParameter(“sid”)));
if(audit==true)
survey.setSIsAudited(true);
else
survey.setSIsAudited(false);
boolean ret=surveydao.updateSurvey(survey);
if(ret==true)
response.sendRedirect(“…/admin/SurveyAudi.jsp”);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=SurveyAudi&ret=false”);
}
}else if(“EditSurvey”.equals(request.getParameter(“op”))){
SurveyDAO surveydao=DAOFactory.getSurveyDAO();
String sid=request.getParameter(“Survey_id”);
synchronized(mutex2){
Survey survey=surveydao.findSurvey(Long.valueOf(request.getParameter(“Survey_id”)));
survey.setSName(request.getParameter(“Survey_name”));
survey.setSAuthor(request.getParameter(“Survey_author”));
survey.setSDesc(request.getParameter(“Survey_description”));
SimpleDateFormat sdf=new SimpleDateFormat(“yyyy-MM-dd”);
try {
survey.setSExpireDate(sdf.parse(request.getParameter(“Survey_ExpireDate”)));
} catch (ParseException e) {
out.println(“wrong DATE format.please check it!”);
}
survey.setTemplet(0L);//???幦??
survey.setSIpRepeat(Boolean.valueOf(request.getParameter(“Survey_ipRepeat”)));
survey.setSIsOpen(Boolean.valueOf(request.getParameter(“Survey_isOpen”)));
if(request.getParameter(“Survey_isImg”)!=null){
if(request.getParameter(“imgfilepath”)!=null)
survey.setSImg(request.getParameter(“imgfilepath”));
}else
survey.setSImg(null);
//System.out.println(request.getParameter(“Survey_isPassword”));
if(request.getParameter(“Survey_isPassword”)!=null){
survey.setSPassword(request.getParameter(“Survey_isPassword”));
}else
survey.setSPassword(null);
if(request.getParameter(“Survry_IPLimit”)!=null){
//survey.setSIpLimitType(request.getParameter(“Survey_ipLimitKinds”));
survey.setSIpRange(request.getParameter(“Survey_ipRange”));
//System.out.print(request.getParameter(“Survey_ipRange”));
}else
{
survey.setSIpLimitType(null);
survey.setSIpRange(null);
}
boolean ret=surveydao.updateSurvey(survey);
//System.out.println(ret);
if(ret==true)
response.sendRedirect(“…/admin/SurveyEdit.jsp?sid=”+sid+“&words=”+URLEncoder.encode(“操作成功!”, “UTF-8”));
else
response.sendRedirect(“…/admin/OpResult.jsp?op=SurveyEdit&ret=false”);
}
}else if(“DelSurvey”.equals(request.getParameter(“op”))){
Long surveyId=Long.valueOf(request.getParameter(“sid”));
SurveyDAO surveydao=DAOFactory.getSurveyDAO();
boolean ret1=surveydao.delSurvey(surveyId);
QuestionDAO questiondao=DAOFactory.getQuestionDAO();
if(ret1==true)
ret1=questiondao.delQuestions(surveyId);
if(ret1==true){
TextDAO tdao=DAOFactory.getTextDAO();
ret1=tdao.delText(surveyId);
}
if(ret1==true){
AnswersheetDAO adao=DAOFactory.getAnswersheetDAO();
ret1=adao.delAnswersheets(surveyId);
}
if(ret1==true)
response.sendRedirect(“…/admin/SurveyAdmin.jsp”);
else
response.sendRedirect(“…/admin/OpResult.jsp?op=SurveyDel&ret=false”);
}
}
/**
-
The doPost method of the servlet.
-
This method is called when a form has its tag value method equals to post.
-
@param request the request send by the client to the server
-
@param response the response send by the server to the client
-
@throws ServletException if an error occurred
-
@throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
最后
终极手撕架构师的学习笔记:分布式+微服务+开源框架+性能优化
op=SurveyDel&ret=false");
}
}
/**
-
The doPost method of the servlet.
-
This method is called when a form has its tag value method equals to post.
-
@param request the request send by the client to the server
-
@param response the response send by the server to the client
-
@throws ServletException if an error occurred
-
@throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
最后
终极手撕架构师的学习笔记:分布式+微服务+开源框架+性能优化
[外链图片转存中…(img-LyD3PDAJ-1715238151273)]