package com.action;
import java.io.*;
import java.util.List;
import java.util.StringTokenizer;
import org.apache.struts.action.*;
import com.dao.SongDAO;
import com.model.SongForm;
import com.model.SongTypeForm;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import com.tools.MyPagination;
import com.tools.StringUtils;
public class SongAction extends Action {
private SongDAO songDAO = null;
MyPagination pagination = null;
StringUtils su=new StringUtils();
public SongAction() {
this.songDAO = new SongDAO();
}
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String action = request.getParameter("action");
// System.out.println("\nscrip*********************action="+action);
if ("main".equals(action)) {
return main(mapping, form, request, response); // 前台首页
} else if ("songQuery".equals(action)) {
return songQuery(mapping, form, request, response); // 查询歌曲信息
} else if ("tryListen".equals(action)) {
return tryListen(mapping, form, request, response); // 查询试听歌曲信息
} else if ("continuePlay".equals(action)) {
return continuePlay(mapping, form, request, response); // 进行歌曲连播
} else if ("songSort".equals(action)) {
return songSort(mapping, form, request, response); // 歌曲排行(试听和下载)
} else if ("navigation".equals(action)) {
return navigation(mapping, form, request, response); // 查询导航栏信息
} else if ("search".equals(action)) {
return search(mapping, form, request, response); // 按条件查询歌曲
} else if ("download".equals(action)) {
return download(mapping, form, request, response); // 文件下载
} else if ("songType".equals(action)) {
return songType(mapping, form, request, response); // 查询歌曲类别
} else if ("adm_search".equals(action)) {
return adm_search(mapping, form, request, response); // 后台查询歌曲信息
} else if ("add".equals(action)){
return adm_add(mapping,form,request,response); //添加歌曲信息
} else if ("checkMusic".equals(action)){
return checkMusic(mapping,form,request,response); //检测歌曲是否已经添加
} else if ("del".equals(action)) {
return del(mapping, form, request, response); // 删除歌曲信息
} else {
request.setAttribute("error", "操作失败!");
return mapping.findForward("error");
}
}
// 主页中的新歌速递
public ActionForward main(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
List<SongTypeForm> list = songDAO.queryType(); // 获取歌曲类别
int songTypeId = 0;
String[][] typeName = new String[6][2];
for (int i = 0; i < list.size(); i++) {
songTypeId = list.get(i).getId();
typeName[i][0] = String.valueOf(list.get(i).getId());
typeName[i][1] = list.get(i).getTypeName();
request.setAttribute("newSongList" + i, songDAO
.query("WHERE songType=" + songTypeId
+ " ORDER BY upTime DESC",5)); // 获取最新上传的5首歌曲
}
request.setAttribute("typeArray", typeName); // 保存类别信息数组到Request中
return mapping.findForward("main");
}
// 歌曲排行
public ActionForward songSort(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String type = request.getParameter("sortType"); //获取表示是试听排行还是下载排行的参数值
if ("hits".equals(type)) {
request.setAttribute("sortType", songDAO
.query(" ORDER BY hits DESC",8)); // 获取试听排行信息
} else if ("download".equals(type)) {
request.setAttribute("sortType", songDAO
.query(" ORDER BY download DESC",8)); // 获取下载排行信息
}
request.setAttribute("sortTypeName", type);
RequestDispatcher requestDispatcher = request
.getRequestDispatcher("/songSort.jsp"); //将页面重定向到歌曲排行榜页面
try {
requestDispatcher.include(request, response); // 此处不能使用forward()方法
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
// 获取导航栏信息
public ActionForward navigation(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
request.setAttribute("navigation", songDAO.queryType()); // 获取歌曲类别信息
RequestDispatcher requestDispatcher = request
.getRequestDispatcher("/navigation.jsp");
try {
requestDispatcher.include(request, response); // 此处不能使用forward()方法
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
// 查找歌曲列表
public ActionForward songQuery(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String strPage = (String) request.getParameter("Page");
int songType = Integer.parseInt(request.getParameter("songType_more")); // 要查看的歌曲类别
int Page = 1;
List<SongForm> list = null;
if (strPage == null) {
pagination = new MyPagination();
list = songDAO.query(" WHERE s.songType=" + songType
+ " ORDER BY s.upTime DESC"); // 获取歌曲信息
int pagesize = 2; // 指定每页显示的记录数
list = pagination.getInitPage(list, Page, pagesize); // 初始化分页信息
request.getSession().setAttribute("pagination", pagination);
} else {
pagination = (MyPagination) request.getSession().getAttribute(
"pagination");
Page = pagination.getPage(strPage);
list = pagination.getAppointPage(Page); // 获取指定页数据
}
if (list.size() > 0) {
request.setAttribute("typeName", list.get(0).getSongType()); // 获取歌曲类别
request.setAttribute("typeID", list.get(0).getSongTypeId()); // 获取歌曲类别ID
}
request.setAttribute("songList", list); // 保存当前页的歌曲信息
request.setAttribute("Page", Page); // 保存的当前页码
return mapping.findForward("songQuery");
}
// 按条件查询歌曲
public ActionForward search(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String strPage = (String) request.getParameter("Page");
int songType = Integer.parseInt(request.getParameter("songType_more")); // 要查看的歌曲类别
String fieldName = request.getParameter("fieldName"); // 获取查询依据
String key = request.getParameter("key"); // 获取查询关键字
System.out.println("获取的查询条件:" + key + fieldName + songType);
String condition = "";
String fieldName_cn = "";
if (songType > 0 && fieldName != null) {
condition = " WHERE s.songType=" + songType + " AND s." + fieldName
+ " LIKE '%" + key + "%' ORDER BY s.upTime DESC";
} else if (songType > 0) {
condition = " WHERE s.songType=" + songType
+ " ORDER BY s.upTime DESC";
} else if (fieldName != null) {
condition = " WHERE s." + fieldName + " LIKE '%" + key
+ "%' ORDER BY s.upTime DESC";
} else {
condition = " ORDER BY s.upTime DESC";
}
if ("songName".equals(fieldName)) {
fieldName_cn = "歌曲名";
} else if ("specialName".equals(fieldName)) {
fieldName_cn = "专辑";
} else if ("singer".equals(fieldName)) {
fieldName_cn = "歌手";
}
int Page = 1;
List<SongForm> list = null;
if (strPage == null) {
pagination = new MyPagination();
list = songDAO.query(condition); // 获取歌曲信息
int pagesize = 2; // 指定每页显示的记录数
list = pagination.getInitPage(list, Page, pagesize); // 初始化分页信息
request.getSession().setAttribute("pagination", pagination);
} else {
pagination = (MyPagination) request.getSession().getAttribute(
"pagination");
Page = pagination.getPage(strPage);
list = pagination.getAppointPage(Page); // 获取指定页数据
}
if (list.size() > 0) {
if (songType > 0) {
// request.set
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
毕业设计,基于 SpringBoot 开发的,含有代码注释,新手也可看懂。毕业设计、期末大作业、课程设计、高分必看,已获高分通过项目。 包含:项目源码、数据库脚本、软件工具、项目说明等,该项目可以作为毕设、课程设计使用。 该系统功能完善、界面美观、操作简单、功能齐全、管理便捷,具有很高的实际应用价值。 里面有部署教程,项目都经过严格调试,确保可以运行! 1. 技术组成 后台框架:SpringBoot 前端:Vue 数据库:MySQL Maven 开发环境:JDK、IDEA、Tomcat
资源推荐
资源详情
资源评论
收起资源包目录
基于 SpringBoot + vue 的音乐网系统 (2)+数据库(毕业设计,包括源码,教程).zip (109个子文件)
tryListen.bmp 2KB
SongAction.class 14KB
SongDAO.class 8KB
SongForm.class 4KB
ConnDB.class 4KB
MyPagination.class 3KB
ManagerAction.class 2KB
ManagerDAO.class 2KB
StringUtils.class 968B
ManagerForm.class 967B
SelfRequestProcessor.class 925B
SongTypeForm.class 784B
.classpath 661B
org.eclipse.wst.common.component 463B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 3KB
upFile_bg.gif 6KB
navigateion_oa.gif 1KB
newWindow_title.gif 808B
btn_bg.gif 501B
navigation_bg.gif 291B
tryListen.gif 241B
title_ico.gif 46B
xalan-2.4.0.jar 974KB
freemarker-2.3.8.jar 784KB
struts.jar 537KB
xwork-2.0.4.jar 445KB
mysql-connector-java-3.1.12-bin.jar 436KB
antlr.jar 350KB
standard.jar 343KB
commons-beanutils.jar 184KB
commons-digester.jar 164KB
ognl-2.6.11.jar 164KB
commons-validator.jar 82KB
jakarta-oro.jar 64KB
commons-logging.jar 37KB
commons-fileupload.jar 22KB
jstl.jar 17KB
jspsmartupload.jar 12KB
SongAction.java 19KB
SongDAO.java 7KB
ConnDB.java 4KB
SongForm.java 3KB
MyPagination.java 2KB
ManagerAction.java 2KB
ManagerDAO.java 1KB
StringUtils.java 754B
ManagerForm.java 571B
SelfRequestProcessor.java 527B
SongTypeForm.java 441B
ad.jpg 18KB
main_title.jpg 16KB
top_bg.jpg 13KB
.jsdtscope 503B
continuePlay.jsp 8KB
tryListen.jsp 7KB
searchResult.jsp 5KB
songList.jsp 5KB
adm_add.jsp 4KB
adm_main.jsp 4KB
main.jsp 4KB
newSongList.jsp 3KB
songSort.jsp 2KB
login.jsp 2KB
right.jsp 2KB
upFile_deal.jsp 1KB
upLrcFile.jsp 1KB
upFile.jsp 1KB
navigation.jsp 1KB
adm_search.jsp 1001B
upLrcFile_deal.jsp 942B
download.jsp 770B
error.jsp 762B
search.jsp 756B
checkMusic.jsp 741B
delok.jsp 486B
addok.jsp 442B
logout.jsp 380B
login_ok.jsp 351B
top.jsp 177B
adm_copyright.jsp 135B
copyright.jsp 133B
index.jsp 125B
db_onLineMusic_Log.LDF 1024KB
gbzj.lrc 2KB
光辉岁月.lrc 2KB
db_onLineMusic_Data.MDF 1024KB
MANIFEST.MF 39B
gbzj.mp3 6.03MB
光辉岁月.mp3 3.75MB
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.jdt.core.prefs 395B
org.eclipse.core.resources.prefs 96B
.project 1KB
connDB.properties 117B
connDB.properties 117B
ApplicationResources.properties 94B
ApplicationResources.properties 94B
db_onlinemusic.sql 4KB
struts-html.tld 72KB
共 109 条
- 1
- 2
gdutxiaoxu
- 粉丝: 1537
- 资源: 3120
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
前往页