myflag step7 增加friend的支持
来源:互联网 发布:怎么克隆网站软件 编辑:程序博客网 时间:2024/06/05 12:44
本周主要做的就是增加了对friend的支持,首先就是在jdbc模型中添加了进一步对user的支持,然后添加了servlet中的信息,考虑到servlet的接口是非常多的,所以对servlet分了几个包,分别是user包,friends包还有flag包。这次增加的servlet接口有对添加朋友信息的处理,获取朋友列表以及更新昵称等借口。
处理friends信息的代码如下:
public voiddoGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException {
response.setContentType(“text/javascript;charset=gb2312”);
PrintWriterpw=new PrintWriter(response.getOutputStream());
JSONObjectjs = new JSONObject();
try { int uid=Integer.parseInt(request.getParameter("id")); FriendsDaofd=new FriendsDao(); List<FriendForList>friend=fd.getMyFriend(uid); js.put("friend", JSONArray.toJSON(friend)); }catch (Exception e) { // TODO: handle exception e.printStackTrace(); js.put("friend", ""); } pw.write(js.toString()); pw.flush(); pw.close(); }
更新昵称的代码如下:
request.setCharacterEncoding(“utf-8”);
PrintWriterpw=new PrintWriter(response.getOutputStream());
int success=0;
try {
int aUid=Integer.parseInt(request.getParameter(“aId”));
int bUid=Integer.parseInt(request.getParameter(“bId”));
if(aUid>0&&bUid>0){
StringnewRemark=request.getParameter(“newRemark”);
FriendsDaofdDao=new FriendsDao();
Booleantemp=fdDao.updateRemark(aUid, bUid, newRemark);
if(temp){
success=1;
}
}
确认请求代码:
response.setContentType(“text/javascript;charset=gb2312”);
PrintWriterpw=new PrintWriter(response.getOutputStream());
// agree: 1代表不同意 2代表同意 0代表为做出决定
JSONObjectjs=new JSONObject();
try {
StringtempUid=request.getParameter(“id”);
if (tempUid==null ||tempUid.equals(“”)) {
tempUid=”0”;
}
int uid=Integer.parseInt(tempUid);
TempFriendDaotd=new TempFriendDao();
List tf=td.getInform(uid);
js.put(“request”, JSONArray.toJSON(tf));
在写完代码之后,请其他同学对我的代码进行了测试,当然在让同学测试之前,我首先自己进行了测试。
测试结果如下:
- myflag step7 增加friend的支持
- MyFlag Step7:flag和个人信息编写
- MyFlag Step7:flag和个人信息编写
- myflag step8:新增user的支持
- myflag step9:新增falg的支持
- myflag step10:flagdao的编写
- myflag step13:接口的完成
- SourceInsight增加支持的文件类型
- STEP7 及模拟器,录像软件的使用
- MyFlag Step6:好友信息的处理
- MyFlag Step 9:Flag相关的功能设计
- MyFlag Step9 :Flag功能相关的设计
- MyFlag Step11 :menupath的移植工作
- MyFlag Step13:打卡功能的初步讨论
- MyFlag Step14: 打卡功能界面的初步
- 为JDBC增加命名参数的支持
- 增加u-boot对ubi的支持
- 增加u-boot对ubi的支持
- js 数组操作
- UML类图
- windows下SVN客户端cleanup失败的修复办法
- java集合操作
- 编译smdk2410 时#make 后出现这种错误,怎么解决
- myflag step7 增加friend的支持
- Java API 对图像的支持
- python 代码命令大全
- Kotlin的学习日志(一)Basic Types
- gmt5绘制网格数据(surface_grdimage)
- 判断是否Ajax请求
- HDFS java操作(二)FileStatus 获取文件属性,globStatus 进行路径过滤
- Keras MNIST
- 存储过程的优缺点