java web博客模块

  • H4_457763
    了解作者
  • 1.6MB
    文件大小
  • rar
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-06-09 12:13
    上传日期
博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块博客模块
博客模块.rar
内容介绍
package com.wy.webiter; import java.io.File; import java.io.UnsupportedEncodingException; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.struts2.ServletActionContext; import org.apache.struts2.interceptor.ServletRequestAware; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.ModelDriven; import com.wy.dao.ObjectDao; import com.wy.model.ArticleInfo; import com.wy.model.Info; import com.wy.model.PhotoInfo; import com.wy.model.ReArticleInfo; import com.wy.model.UserInfo; public class UserInfoAction extends ActionSupport implements ModelDriven<UserInfo>, ServletRequestAware { private UserInfo userInfo = new UserInfo(); private String hql = ""; private ObjectDao<UserInfo> objectDao = null; protected HttpServletRequest request; public UserInfo getModel() { return userInfo; } public void setServletRequest(HttpServletRequest request) { this.request = request; } // 删除朋友信息 public String friend_delete() { String friendsTypes[] = request.getParameterValues("friends"); if (friendsTypes != null) { String account = (String) request.getSession().getAttribute( "account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); UserInfo user = objectDao.queryFrom(hql); String date_types = user.getFriendType(); for (String type : friendsTypes) { date_types = com.wy.tools.ValidateExpression.deleteString( date_types, type); } user.setFriendType(date_types); objectDao.updateT(user); } return friend_query(); } // 后台查询用户 public String friend_query() { String account = (String) request.getSession().getAttribute("account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); userInfo = objectDao.queryFrom(hql); String friend = userInfo.getFriendType(); if (!friend.equals("")) { request.setAttribute("friends", friend.split(",")); } return "friend_query"; } // 添加好友 public String friend_add() { boolean flag = true; objectDao = new ObjectDao<UserInfo>(); String account = (String) request.getSession().getAttribute("account"); UserInfo user = objectDao.queryFrom("from UserInfo where account = '" + account + "'"); String friends = user.getFriendType(); UserInfo userInfo = (UserInfo) request.getSession().getAttribute( "userInfo"); String account1 = userInfo.getAccount(); // 获取访问博客的用户名 if (friends == null || friends.equals("")) { user.setFriendType(account1); } else { String types[] = friends.split(","); for (String type1 : types) { if (account1.equals(type1)) { flag = false; } } user.setFriendType(userInfo.getFriendType() + "," + account1); } String result = "该好友已经存在,操作失败!"; if (flag) { objectDao = new ObjectDao<UserInfo>(); System.out.println(objectDao.updateT(user)); result = "加入好友成功!"; } request.setAttribute("account1", account1); request.setAttribute("sign", "18"); request.setAttribute("result", result); return "operationUser"; } // 删除相册类别操作 public String phtType_delete() { String phtTypes[] = request.getParameterValues("type"); if (phtTypes != null) { String account = (String) request.getSession().getAttribute( "account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); UserInfo user = objectDao.queryFrom(hql); String date_phtType = user.getPicType(); for (String phtType : phtTypes) { date_phtType = com.wy.tools.ValidateExpression.deleteString( date_phtType, phtType); hql = "from PhotoInfo where author = '" + account + "' and photoType = '" + phtType + "'"; ObjectDao<PhotoInfo> dao = new ObjectDao<PhotoInfo>(); List<PhotoInfo> list = dao.queryList(hql); for (PhotoInfo photoInfo : list) { dao.deleteT(photoInfo); String path = request.getRealPath("/" + photoInfo.getPhotoAddress()); File file = new File(path); if (file.exists()) { file.delete(); } } } user.setPicType(date_phtType); objectDao.updateT(user); } request.setAttribute("sign", "13"); return "operationUser"; } // 修改相片类别名称 public String phtType_update() { String oldType = request.getParameter("oldType"); String newsType = request.getParameter("newsType"); String account = (String) request.getSession().getAttribute("account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); UserInfo user = objectDao.queryFrom(hql); String date_phtType = user.getPicType(); String arrays[] = date_phtType.split(","); boolean flag = true; for (String array : arrays) { if (array.equals(newsType)) { flag = false; } } if (flag) { if (!newsType.equals("")) { date_phtType = com.wy.tools.ValidateExpression.deleteString( date_phtType, oldType); date_phtType = date_phtType.trim(); if (date_phtType.equals("")) { date_phtType = newsType; } else { date_phtType = date_phtType + "," + newsType; } user.setPicType(date_phtType); objectDao.updateT(user); hql = "from PhotoInfo where author = '" + account + "' and photoType = '" + oldType + "'"; ObjectDao<PhotoInfo> dao = new ObjectDao<PhotoInfo>(); List<PhotoInfo> list = dao.queryList(hql); for (PhotoInfo photoInfo : list) { photoInfo.setPhotoType(newsType); System.out.println(newsType); dao.updateT(photoInfo); } } } request.setAttribute("sign", "14"); return "operationUser"; } // 查询并添加相片类别信息 public String phtType_query() { boolean flag = true; String account = (String) request.getSession().getAttribute("account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); UserInfo user = objectDao.queryFrom(hql); String pht_type = user.getPicType(); // 添加类别 if (!userInfo.getPicType().equals("")) { String arrays[] = pht_type.split(","); for (String array : arrays) { if (array.equals(userInfo.getPicType())) { this.addFieldError("pht_type", "您输入的相册类别重复,请重新输入!"); flag = false; } } if (null == pht_type || pht_type.equals("")) { user.setPicType(userInfo.getPicType()); } else { user .setPicType(user.getPicType() + "," + userInfo.getPicType()); } if (flag) { objectDao.updateT(user); user = objectDao.queryFrom(hql); pht_type = user.getPicType(); } } // 查询类别 pht_type = pht_type.trim(); if (!pht_type.equals("")) { String pht_types[] = pht_type.split(","); request.setAttribute("pht_types", pht_types); } return SUCCESS; } // 转向添加文章的页面,这里需要将文章的类别转换成数组 public String forwardAddArticle() { String account = (String) request.getSession().getAttribute("account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); UserInfo userInfo = (UserInfo) objectDao.queryFrom(hql); String type = userInfo.getArtType(); String types[] = type.split(","); request.setAttribute("types", types); return "forwardAddArticle"; } // 修改文章类别名称 public String artType_update() { String oldType = request.getParameter("oldType"); String newsType = request.getParameter("newsType"); String account = (String) request.getSession().getAttribute("account"); hql = "from UserInfo where account = '" + account + "'"; objectDao = new ObjectDao<UserInfo>(); UserInfo user = objectDao.queryFrom(hql); String date_artType = user.getArtType(); String arrays[] = date_artType.split(","); boolean flag = t
评论
    相关推荐
    • Java
      Java 对于Java练习
    • java
      Java Java基础
    • Java
      Java 我创建的Java项目
    • JAVA教程
      一本非常不错的清华大学java教程,讲解非常详细,看了就知道。
    • Java Cipher
      Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码 Java Cipher 加密和解密工具 附带源码
    • javabank
      Java银行 Java com的模拟操作将在bancárias上发布! 要求:Java 8。
    • java 李兴华
      java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java 李兴华 java ...
    • Java204
      支持中文,支持动态注释的超强Java语言反编译器。 注意:Java204的工作目录中不能包含中文字符!! 支持现有所有Java环境产生的Class代码,而最重要的是它生成的源代码可读性极好,又充分考虑了国人的Java编码习惯,...
    • java程序
      java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点java程序-吃点点
    • Java
      Java 2021/02/19 .java Main.java 学生.java Bmi.java 。班级 Bmi类 主类 MyBmi.class 学生班 学生样本类 2021/02/20 .java DeleteFile.java WriteFile.java MyDataPrint.java 。班级 DeleteFile.class ...