📄 querychatroomsdo.java
字号:
package com.lovo.servlet;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import javax.servlet.ServletContext;
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.lovo.bo.ChatroomBO;
import com.lovo.factory.BOFactory;
import com.lovo.po.ChatroomPO;
public class QueryChatroomsDO extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
ServletContext application=this.getServletContext();
String home = request.getParameter("home");
ChatroomBO ChatroomBO=BOFactory.getChatroomBOInstance();
List<ChatroomPO> chatroomList=null;
try {
chatroomList = ChatroomBO.queryAllChatroom();
} catch (SQLException e) {
e.printStackTrace();
}
application.setAttribute("chatroomList", chatroomList);
if(home == null) {
response.sendRedirect("web/jsp/chatroomShow.jsp");
} else {
response.sendRedirect("web/jsp/homechatroomshow.jsp");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -