⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getprivatechatdo.java

📁 一个bbs论坛系统
💻 JAVA
字号:
package com.lovo.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
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.po.PrivateChatPO;
import com.lovo.po.UserPO;

public class GetPrivateChatDO extends HttpServlet{


	private static final long serialVersionUID = 7652108736999314237L;
	protected void doGet(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();
		HttpSession session = request.getSession(true);
		
		PrintWriter out = response.getWriter();

		List<PrivateChatPO> privateList=(List<PrivateChatPO>)application.getAttribute("privateList");
		if(privateList==null){
			privateList=new ArrayList<PrivateChatPO>();
			application.setAttribute("privateList", privateList);
		}
		String sendContent="";
		UserPO currentUser=(UserPO)session.getAttribute("user");
		for(int i=0;i<privateList.size();i++){
			UserPO user1PO=((PrivateChatPO)privateList.get(i)).getSendUser();
			UserPO user2PO=((PrivateChatPO)privateList.get(i)).getReceiveUser();
			String privateChat=((PrivateChatPO)privateList.get(i)).getPrivateChat();
			if(currentUser.getName().equals(user1PO.getName())){
				sendContent=sendContent+"你对"+user2PO.getName()+"说: "+privateChat+"<br>";	
			}
			if(currentUser.getName().equals(user2PO.getName())){
				sendContent=sendContent+user1PO.getName()+"对你说: "+privateChat+"<br>";
			}	
		}
		out.print(sendContent);
		return;
	}
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		this.doGet(request, response);
	}
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -