package name.chenye.friends.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import name.chenye.friends.integration.dao.impl.*;
import name.chenye.friends.dto.*;
import java.util.*;
/**
* Servlet implementation class for Servlet: ListFriendServlet
*
*/
public class ListFriendServlet extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
static final long serialVersionUID = 1L;
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public ListFriendServlet() {
super();
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
request.setCharacterEncoding("gbk");
List<FriendWithGroupInfoDTO> friendWithGroupInfoList=new ArrayList<FriendWithGroupInfoDTO>();
initFriendWithGroupInfoList(friendWithGroupInfoList);
//System.out.println(friendWithGroupInfoList.get(0).getLivenow());
request.setAttribute("friendWithGroupInfoList", friendWithGroupInfoList);
request.getRequestDispatcher("/listFriend.jsp").forward(request, response);
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}
/**
*
*/
public void initFriendWithGroupInfoList(List<FriendWithGroupInfoDTO> list)
{
String groupName=null;
String groupBrief=null;
int groupId=0;
List<FriendDTO> friendList=new ArrayList<FriendDTO>();
FriendJdbcDAO fjd=new FriendJdbcDAO();
friendList=fjd.listFriend();
GroupJdbcDAO gjd=new GroupJdbcDAO();
List<GroupDTO> groupList=new ArrayList<GroupDTO>();
groupList=gjd.selectGroup();
for(int i=0;i<friendList.size();i++)
{
groupName=null;
groupBrief=null;
groupId=friendList.get(i).getGroupId();
for(int j=0;j<groupList.size();j++)
{
if(groupList.get(j).getGroupId()==groupId)
{
groupName=groupList.get(j).getName();
groupBrief=groupList.get(j).getBrief();
break;
}
}
if(groupName!=null&&groupBrief!=null)
{
FriendWithGroupInfoDTO friendWithGroupInfoDTO=
new FriendWithGroupInfoDTO(friendList.get(i),groupName,groupBrief);
list.add(friendWithGroupInfoDTO);
}
else
{
groupName="分组失效";
groupBrief="联系系统管理员处理";
FriendWithGroupInfoDTO friendWithGroupInfoDTO=
new FriendWithGroupInfoDTO(friendList.get(i),groupName,groupBrief);
list.add(friendWithGroupInfoDTO);
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
用servlet+jsp实现的MVCdemo
共51个文件
class:14个
java:14个
jsp:5个
5星 · 超过95%的资源 需积分: 10 17 下载量 39 浏览量
2012-09-14
18:22:35
上传
评论
收藏 1.99MB RAR 举报
温馨提示
用servlet+jsp实现的MVCdemo 用servlet+jsp实现的MVCdemo
资源推荐
资源详情
资源评论
收起资源包目录
friends.rar (51个子文件)
friends
.project 1KB
.settings
.jsdtscope 454B
org.eclipse.core.resources.prefs 217B
org.eclipse.wst.common.component 493B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.common.project.facet.core.xml 319B
org.eclipse.jst.common.project.facet.core.prefs 356B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.name 6B
src
name
chenye
friends
integration
dao
impl
GroupJdbcDAO.java 1KB
FriendJdbcDAO.java 933B
GroupDAO.java 121B
servlet
AddFriend.java 2KB
DeleteFriendServlet.java 2KB
PreAddFriendServlet.java 2KB
AddGroupServlet.java 2KB
DeleteGroupServlet.java 2KB
ListFriendServlet.java 3KB
ListGroupServlet.java 2KB
dto
FriendDTO.java 915B
GroupDTO.java 483B
FriendWithGroupInfoDTO.java 754B
common
DatabaseService.java 705B
build
classes
name
chenye
friends
integration
dao
impl
FriendJdbcDAO.class 2KB
GroupJdbcDAO.class 2KB
GroupDAO.class 176B
servlet
ListFriendServlet.class 3KB
ListGroupServlet.class 2KB
AddGroupServlet.class 2KB
AddFriend.class 3KB
DeleteFriendServlet.class 2KB
DeleteGroupServlet.class 2KB
PreAddFriendServlet.class 2KB
dto
GroupDTO.class 940B
FriendDTO.class 1KB
FriendWithGroupInfoDTO.class 1KB
common
DatabaseService.class 1KB
WebContent
addFriend.jsp 10KB
listGroup.jsp 895B
WEB-INF
mysql-connector-java-5.1.22-bin.jar 813KB
web.xml 3KB
lib
mysql-connector-java-5.1.22-bin.jar 813KB
jstl.jar 20KB
standard.jar 503KB
index.jsp 547B
META-INF
MANIFEST.MF 39B
addGroup.jsp 2KB
js
myTools.js 790B
dateSelector.js 7KB
listFriend.jsp 1KB
.classpath 901B
共 51 条
- 1
资源评论
- 未来AI编程2012-11-29可以运行,需要调试一下。
- tinalucy672019-03-07谢谢分享!
ccsnailcy
- 粉丝: 1
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功