资源简介

该博客系统使用了SSH框架,采用JSP语言开发,是学校中某个课程的课程设计作品,压缩包内含有项目的源码以及数据库文件,直接导入即可运行,项目完善,是良心资源!软件仅提供使用权,所有权归开发者所有。

资源截图

代码片段和文件信息

package club.teenshare.actions;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import com.opensymphony.xwork2.ActionSupport;

import club.teenshare.beans.Admin;
import club.teenshare.beans.Comments;
import club.teenshare.beans.Playlist;
import club.teenshare.beans.Plsong;
import club.teenshare.beans.Song;
import club.teenshare.beans.User;
import club.teenshare.dao.CommentsDAO;
import club.teenshare.dao.HibernateSessionFactory;
import club.teenshare.dao.PlaylistDAO;
import club.teenshare.dao.PlsongDAO;
import club.teenshare.dao.SongDAO;
import club.teenshare.dao.UserDAO;

public class AdminAction extends ActionSupport {

HttpSession httpSession = ServletActionContext.getRequest().getSession();
private Song song;

public Song getSong(){
return this.song;
}
public void setSong(Song song){
this.song = song;
}

@Override
public void validate() {
Admin admin = (Admin)httpSession.getAttribute(“currentAdmin“);
if(admin == null){
addFieldError(“notLogin“ “您还未登录或登录已过期“);
}
}

public String initAdmin() throws Exception{
Session session = HibernateSessionFactory.getSession();
try {
Transaction ts = session.beginTransaction();
SongDAO sdao = new SongDAO(); //定义songdao实例,用户获取所有歌曲的列表
List allSongs = sdao.findAll();

UserDAO udao = new UserDAO(); //定义userdao实例,用于获取所有用户的列表
List allUsers = udao.findAll();

CommentsDAO cdao = new CommentsDAO();
List allComments = cdao.findAll();
ts.commit();
session.close();
httpSession.removeAttribute(“allSongs“);
httpSession.removeAttribute(“allUsers“);
httpSession.removeAttribute(“allComments“);
httpSession.setAttribute(“allSongs“ allSongs);
httpSession.setAttribute(“allUsers“ allUsers);
httpSession.setAttribute(“allComments“ allComments);
return SUCCESS;
} catch (Exception e) {
e.printStackTrace();
session.close();
addFieldError(“initError“ “后台信息初始化失败!“);
return ERROR;
}


}
//创建关于用户显示个人上传信息的action
public String ShowSongsAdmin() throws Exception{
Session session = HibernateSessionFactory.getSession();

try {
Transaction ts = session.beginTransaction();
String searchHql = “from Song s order by s.uptime desc“;
Query query = session.createQuery(searchHql);
//传入查询条件参数
List allSongs = query.list();
ts.commit();
httpSession.removeAttribute(“allSongs“);//去除掉旧的session存储
httpSession.setAttribute(“allSongs“ allSongs);
//关闭掉Session
session.close();
return “allSongs“;
} catch (Exception e) {
session.close();
e.printStackTrace();
addFieldError(“userError“ “歌曲信息记录查询失败,待会儿再试啊~“);
return ERROR;
}
}
//显示歌单信息
public String ShowPlaylistAdmin() throws Exception{
Session session = HibernateSess

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件       10257  2018-12-12 11:42  musicdb.sql
     目录           0  2018-11-22 14:50  OnlineMusic\
     文件        1675  2018-11-22 14:50  OnlineMusic\.classpath
     文件         452  2018-12-04 17:05  OnlineMusic\.myhibernatedata
     文件        1061  2018-10-22 20:16  OnlineMusic\.project
     目录           0  2018-11-29 09:17  OnlineMusic\.settings\
     文件         564  2018-10-22 19:21  OnlineMusic\.settings\.jsdtscope
     文件         238  2018-11-29 09:17  OnlineMusic\.settings\com.genuitec.runtime.libraries.xml
     文件         364  2018-10-22 19:21  OnlineMusic\.settings\org.eclipse.jdt.core.prefs
     文件         492  2018-10-22 20:16  OnlineMusic\.settings\org.eclipse.wst.common.component
     文件         515  2018-11-22 14:50  OnlineMusic\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2018-10-22 19:21  OnlineMusic\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2018-10-22 19:21  OnlineMusic\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2018-12-09 11:10  OnlineMusic\src\
     目录           0  2018-11-22 14:45  OnlineMusic\src\club\
     目录           0  2018-12-11 09:00  OnlineMusic\src\club\teenshare\
     目录           0  2018-12-03 19:59  OnlineMusic\src\club\teenshare\actions\
     文件        8850  2018-12-10 17:48  OnlineMusic\src\club\teenshare\actions\AdminAction.java
     文件        2640  2018-12-02 15:25  OnlineMusic\src\club\teenshare\actions\CommentsAction.java
     文件        2286  2018-12-10 18:14  OnlineMusic\src\club\teenshare\actions\InitAction.java
     文件        4293  2018-12-10 17:55  OnlineMusic\src\club\teenshare\actions\LoginAction.java
     文件        6938  2018-12-10 18:23  OnlineMusic\src\club\teenshare\actions\PlaylistAction.java
     文件        3770  2018-11-28 20:28  OnlineMusic\src\club\teenshare\actions\ShowAction.java
     文件        9685  2018-12-10 17:52  OnlineMusic\src\club\teenshare\actions\SongsAction.java
     文件        6634  2018-12-02 17:38  OnlineMusic\src\club\teenshare\actions\UserAction.java
     目录           0  2018-11-22 14:51  OnlineMusic\src\club\teenshare\beans\
     文件         891  2018-11-22 14:51  OnlineMusic\src\club\teenshare\beans\Admin.hbm.xml
     文件        1120  2018-11-22 14:51  OnlineMusic\src\club\teenshare\beans\Admin.java
     文件        1106  2018-11-29 15:02  OnlineMusic\src\club\teenshare\beans\Comments.hbm.xml
     文件        1290  2018-11-29 15:00  OnlineMusic\src\club\teenshare\beans\Comments.java
     文件        1264  2018-12-10 10:17  OnlineMusic\src\club\teenshare\beans\Playlist.hbm.xml
............此处省略311个文件信息

评论

共有 条评论