?? indexservlet.java
字號:
package com.yxq.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.yxq.dao.ArticleDao;
import com.yxq.dao.ArticleTypeDao;
import com.yxq.dao.FriendDao;
import com.yxq.dao.LogonDao;
import com.yxq.dao.PhotoDao;
import com.yxq.dao.WordDao;
import com.yxq.valuebean.MasterBean;
public class IndexServlet extends HttpServlet {
private static MasterBean masterBean;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
HttpSession session=request.getSession();
ArticleDao articleDao = new ArticleDao();
ArticleTypeDao artTypeDao = new ArticleTypeDao();
PhotoDao photoDao = new PhotoDao();
WordDao wordDao=new WordDao();
FriendDao friendDao=new FriendDao();
/********** 獲取在主頁面的內容顯示區中顯示的內容 *********/
//從tb_article數據表中獲取前3篇文章
List articleList=articleDao.queryArticle(-1,null);
request.setAttribute("articleList",articleList);
//從tb_photo數據表中獲取前8張照片
List photoList=photoDao.queryPhoto("sub");
request.setAttribute("photoList",photoList);
/********** 獲取在頁面側欄中顯示的內容 *********/
/* 從tb_word數據表中獲取前5條留言 */
List wordList=wordDao.queryWord("sub");
session.setAttribute("wordList",wordList);
/* 從tb_article數據表中獲取前5章推薦文章 */
List artTJList=articleDao.queryArticle(4,"sub");
session.setAttribute("artTJList",artTJList);
/* 從tb_friend數據表中獲取前5位好友信息 */
List friendList=friendDao.queryFriend("sub");
session.setAttribute("friendList", friendList);
/********** 獲取文章類別 *******************/
/* 從tb_articleType數據表中獲取文章類別 */
List artTypeList=artTypeDao.queryTypeList();
session.setAttribute("artTypeList",artTypeList);
/*********** 保存博主信息 *****************/
session.setAttribute("master",masterBean);
RequestDispatcher rd=request.getRequestDispatcher("/front/FrontIndex.jsp");
rd.forward(request,response);
}
static{
LogonDao logonDao=new LogonDao();
masterBean=logonDao.getMaster();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -