基于javaweb+springboot的音乐网站音乐平台(java+Springboot+ssm+mysql+maven+jsp)
一、项目简述
功能: 用户管理模块:用户登录、用户注册、修改密码 榜单列表模块:动态地从数据库中获取歌曲的链接和数据 在榜单中显示 歌曲搜索模块:在首页的搜索框中可以输入关键字进行歌 曲的模糊搜索 歌曲收藏模块:在榜单列表中或搜索页面中可以点击歌曲 进行收藏 我的音乐模块:收藏的歌曲会被添加到我的音乐列表中, 在我的音乐列表中也可以对歌曲进行删除操作 音乐播放器模块:在榜单、搜索页面和我的音乐列表等地 方点击歌曲可以炼专到播放页面进行播放。播放页面显示 播放进度条,删除歌曲,暂停等操作。播放页面背景为模 糊背景,根据歌手的专辑图片自动变化。
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP +SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + Bootstrap+ maven 等等。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
Object data = null;String statusMsg = "";int statusCode = 200;LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();if (tbStatus != null && tbStatus.length() > 0) {condition.put("tb_status='" + tbStatus + "'", "and");}if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();buf.append("(");buf.append("test_name like '%").append(keyword).append("%'");buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");
@RequestParam(required = false) String keyword,@RequestParam(defaultValue = "ml_id", required = false) String order,@RequestParam(defaultValue = "desc", required = false) String desc,@RequestParam(required = false) String user_name, @RequestParam(required = false) String user_password) {
// System.out.println("我的音乐显示列表前收藏的歌曲id:" + song_id);String user_Id = null;try {user_Id = myMusicService.getUserById(user_name, user_password);} catch (Exception e) {}int userId = 0;try {// 判断字符串是否是数字,并且抛出异常boolean NotisNum = (user_Id.equals("null"));// System.out.println(NotisNum);if (!NotisNum) {userId = Integer.parseInt(user_Id);}} catch (Exception e) {}
@RequestParam(required = false) int song_id, @RequestParam(required = false) String user_name,@RequestParam(required = false) String user_password, @RequestParam(required = false) String songName) {WebResponse webResponse = new WebResponse();MusicLink musicLink = new MusicLink();User user = new User();System.out.println("歌曲id:" + song_id + " 用户名:" + user_name + " 户用密码:" + user_password);Object data = null;String statusMsg = "";int statusCode = 200;String user_Id = null;
User user = new User();user.setUser_id(userId);System.out.println("登录的id:" + user.getUser_id());System.out.println("登录的用户名:" + session.getAttribute(tname));System.out.println("前端,用户名:" + user_name + " 密码:" + user_password);System.out.println("根据前端在数据库中查找到的用户名:" + tname + " 用户的id:" + userId);// 用户名和密码匹配不成功,则返回的用户名为空if (tname == null) {System.out.println("用户不存在");System.out.println();
@RequestMapping(value = "/getOneUser", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")@ResponseBodypublic WebResponse getOneTest(@RequestParam(defaultValue = "正常", required = false) String tbStatus) {LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();condition.put("tb_status='" + tbStatus + "'", "");User userVo = this.userService.getOne(condition);Object data = null;String statusMsg = "";if (userVo != null && userVo.getUser_id() > 0) {data = userVo;statusMsg = "根据条件获取单条数据成功!!!";} else {statusMsg = "no record!!!";}return webResponse.getWebResponse(statusMsg, data);}
int count = this.musicLinkService.getCount(condition, field);if (order != null && order.length() > 0 & "desc".equals(desc)) {order = order + " desc";}// 从数据库中获取数据,并把对象的结果集存到list列表中List<MusicLink> list = this.musicLinkService.getList(condition, pageNo, pageSize, order, field);Map<Object, Object> map = new HashMap<Object, Object>();map.put("total", count);// 如果数据库有15条音乐,则list中有15个对象,则size的大小为15int size = list.size();if (size > 0) {List<MusicLink> listFont = new ArrayList<MusicLink>();MusicLink vo;MusicLink voFont = new MusicLink();// 循环将获取到的对象及结构属性克隆到一个新的voFont对象中,并保存到动态数组中
String user_name = request.getParameter("user_name");String newUser_password = request.getParameter("newUser_password");try {uId = (int) this.userService2.resetPassword(user_name, newUser_password);System.out.println("修改密码返回的id:" + uId);} catch (Exception e) {}return webResponse.getWebResponse(statusCode, statusMsg, data);}// 用户注册@RequestMapping(value = "/addOrEditUser", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")@ResponseBodypublic WebResponse addOrEditTest(HttpServletRequest request, HttpServletResponse response, HttpSession session,String user_id, @RequestParam(required = false) String user_name,@RequestParam(required = false) String user_password) {Object data = null;String statusMsg = "用户名已存在,请重新注册!";
try {// 判断字符串是否是数字,并且抛出异常// boolean NotisNum// =(user_Id.equals(null)||user_Id.equals("")||user_Id.equals("null"));boolean NotisNum = (jSong.equals("null"));if (!NotisNum) {my_Id = Integer.parseInt(jSong);}} catch (Exception e) {}if (my_Id > 0) {statusCode = 201;statusMsg = "已收藏,请不要重复收藏!";
buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");buf.append(" or ");buf.append("other like '%").append(keyword).append("%'");buf.append(")");condition.put(buf.toString(), "and");}String field = null;if (condition.size() > 0) {condition.put(condition.entrySet().iterator().next().getKey(), "");}int count = this.userService.getCount(condition, field);if (order != null && order.length() > 0 & "desc".equals(desc)) {order = order + " desc";}List<User> list = this.userService.getList(condition, pageNo, pageSize, order, field);Map<Object, Object> map = new HashMap<Object, Object>();map.put("total", count);int size = list.size();if (size > 0) {List<User> listFont = new ArrayList<User>();User vo;
// System.out.println(NotisNum);if (!NotisNum) {userId = Integer.parseInt(user_Id);}} catch (Exception e) {}System.out.println("歌曲名:" + songName);String jSong = this.musicLinkService.judgeSong(songName, userId);int my_Id = 0;try {// 判断字符串是否是数字,并且抛出异常// boolean NotisNum// =(user_Id.equals(null)||user_Id.equals("")||user_Id.equals("null"));boolean NotisNum = (jSong.equals("null"));if (!NotisNum) {my_Id = Integer.parseInt(jSong);
if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();buf.append("(");buf.append("test_name like '%").append(keyword).append("%'");buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");buf.append(" or ");buf.append("other like '%").append(keyword).append("%'");buf.append(")");condition.put(buf.toString(), "and");}String field = null;if (condition.size() > 0) {condition.put(condition.entrySet().iterator().next().getKey(), "");}int count = this.userService.getCount(condition, field);if (order != null && order.length() > 0 & "desc".equals(desc)) {order = order + " desc";}List<User> list = this.userService.getList(condition, pageNo, pageSize, order, field);Map<Object, Object> map = new HashMap<Object, Object>();map.put("total", count);int size = list.size();
public String getAdminTestList(HttpServletRequest request, HttpServletResponse response, HttpSession session,@RequestParam(defaultValue = "1", required = false) Integer pageNo,@RequestParam(defaultValue = "10", required = false) Integer pageSize,@RequestParam(defaultValue = "正常", required = false) String tbStatus,@RequestParam(required = false) String keyword,@RequestParam(defaultValue = "test_id", required = false) String order,@RequestParam(defaultValue = "desc", required = false) String desc) {Object data = null;String statusMsg = "";int statusCode = 200;LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();if (tbStatus != null && tbStatus.length() > 0) {condition.put("tb_status='" + tbStatus + "'", "and");}if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();
return webResponse.getWebResponse(statusCode, statusMsg, data);}int num = this.userService.update(user);if (num > 0) {statusMsg = "成功修改!!!";} else {statusCode = 202;statusMsg = "update false";}return webResponse.getWebResponse(statusCode, statusMsg, data);}
@RequestParam(defaultValue = "1", required = false) Integer pageNo,@RequestParam(defaultValue = "30", required = false) Integer pageSize,@RequestParam(defaultValue = "正常", required = false) String tbStatus,@RequestParam(required = false) String keyword,@RequestParam(defaultValue = "ml_id", required = false) String order,@RequestParam(defaultValue = "desc", required = false) String desc) {Object data = null;String statusMsg = "";int statusCode = 200;LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();/** if (tbStatus != null && tbStatus.length() > 0) { condition.put("tb_status='"* + tbStatus + "'", "and"); }*/if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();buf.append("(");buf.append("test_name like '%").append(keyword).append("%'");buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");
List<User> list = this.userService.getList(condition, pageNo, pageSize, order, field);Map<Object, Object> map = new HashMap<Object, Object>();map.put("total", count);int size = list.size();if (size > 0) {map.put("list", list);data = map;statusMsg = "根据条件获取分页数据成功!!!";} else {map.put("list", list);data = map;statusCode = 202;statusMsg = "no record!!!";}return JSON.toJSONString(data);
return webResponse.getWebResponse(statusCode, statusMsg, data);}User userVo = this.userService.getById(user_idNumeri);User user = new User();BeanUtils.copyProperties(userVo, user); // 浅复制,重要boolean isAdd = false;return this.addOrEditUser(request, response, session, data, user, user_name, user_password, isAdd);}/** */private WebResponse addOrEditUser(HttpServletRequest request, HttpServletResponse response, HttpSession session,Object data, User user, String user_name, String user_password, boolean isAdd) {String statusMsg = "";Integer statusCode = 200;if (user_name != null && !("".equals(user_name.trim()))) {
Integer statusCode = 200;Map<String, String> paramMap = new HashMap<String, String>();paramMap.put("user_name", user_name);paramMap.put("user_password", user_password);data = paramMap;User user = new User();user.setUser_id(userId);System.out.println("登录的id:" + user.getUser_id());System.out.println("登录的用户名:" + session.getAttribute(tname));System.out.println("前端,用户名:" + user_name + " 密码:" + user_password);System.out.println("根据前端在数据库中查找到的用户名:" + tname + " 用户的id:" + userId);// 用户名和密码匹配不成功,则返回的用户名为空if (tname == null) {System.out.println("用户不存在");System.out.println();statusMsg = "用户或密码错误!";statusCode = 201;return webResponse.getWebResponse(statusCode, statusMsg, data);} else {statusCode = 200;
* * * @Responsebody 注解表示该方法的返回的结果直接写入 HTTP 响应正文(ResponseBody)中,* 一般在异步获取数据时使用,通常是在使用 @RequestMapping 后,返回值通常解析为跳转路径,* 加上 @Responsebody 后返回结果不会被解析为跳转路径,而是直接写入HTTP 响应正文中。 * 作用: 该注解用于将Controller的方法返回的对象,通过适当的HttpMessageConverter转换为指定格式后,写入到Response对象的body数据区。* *** * @RequestParam(value="aa" required=false)* 1.可以对传入参数指定参数名* * // 下面的对传入参数指定为aa,如果前端不传aa参数名,会报错 * @RequestParam(value="aa") String inputStr * * 2、可以通过required=false或者true来要求@RequestParam配置的前端参数是否一定要传 * * 3、如果@requestParam注解的参数是int类型,并且required=false,此时如果不传参数的话,会报错。原因是,required=false时,不传参数的话,* 会给参数赋值null,这样就会把null赋值给了int,因此会报错。*
// MyMusicService myMusicService2;// 歌曲收藏@RequestMapping(value = "/addMusicCollect", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")@ResponseBodypublic WebResponse addMusicCollect(HttpServletRequest request, HttpServletResponse response, HttpSession session,@RequestParam(required = false) String user_name) {WebResponse webResponse = new WebResponse();MyMusic myMusic = new MyMusic();System.out.println("接收到的用户名:" + user_name);Integer statusCode = 200;// 数据库插入语句,对应xml文件的insertthis.myMusicService.insert(myMusic);webResponse.setStatusCode(statusCode);return webResponse;}// 从数据库中获取歌曲数据,在我的音乐中显示@RequestMapping(value = "/getMyMusicList", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")@ResponseBodypublic WebResponse getMyMusicList(HttpServletRequest request, HttpServletResponse response, HttpSession session,@RequestParam(defaultValue = "1", required = false) Integer pageNo,
map.put("list", listFont);data = map;statusMsg = "根据条件获取分页数据成功!!!";} else {map.put("list", list);data = map;statusCode = 202;statusMsg = "no record!!!";return webResponse.getWebResponse(statusCode, statusMsg, data);}}catch (Exception e){}return webResponse.getWebResponse(statusCode, statusMsg, data);
if (condition.size() > 0) {condition.put(condition.entrySet().iterator().next().getKey(), "");}int count = this.musicLinkService.getCount(condition, field);if (order != null && order.length() > 0 & "desc".equals(desc)) {order = order + " desc";}// 从数据库中获取数据,并把对象的结果集存到list列表中List<MusicLink> list = this.musicLinkService.getList(condition, pageNo, pageSize, order, field);Map<Object, Object> map = new HashMap<Object, Object>();map.put("total", count);// 如果数据库有15条音乐,则list中有15个对象,则size的大小为15int size = list.size();if (size > 0) {List<MusicLink> listFont = new ArrayList<MusicLink>();MusicLink vo;MusicLink voFont = new MusicLink();// 循环将获取到的对象及结构属性克隆到一个新的voFont对象中,并保存到动态数组中for (int i = 0; i < size; i++) {
Object data = null;String statusMsg = "";int statusCode = 200;LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();if (tbStatus != null && tbStatus.length() > 0) {condition.put("tb_status='" + tbStatus + "'", "and");}if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();buf.append("(");buf.append("test_name like '%").append(keyword).append("%'");buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");buf.append(" or ");buf.append("other like '%").append(keyword).append("%'");buf.append(")");condition.put(buf.toString(), "and");}String field = null;if (condition.size() > 0) {
*/if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();buf.append("(");buf.append("test_name like '%").append(keyword).append("%'");buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");buf.append(" or ");buf.append("other like '%").append(keyword).append("%'");buf.append(")");condition.put(buf.toString(), "and");}String field = null;if (condition.size() > 0) {condition.put(condition.entrySet().iterator().next().getKey(), "");
if (condition.size() > 0) {condition.put(condition.entrySet().iterator().next().getKey(), "");}int count = this.userService.getCount(condition, field);if (order != null && order.length() > 0 & "desc".equals(desc)) {order = order + " desc";}List<User> list = this.userService.getList(condition, pageNo, pageSize, order, field);Map<Object, Object> map = new HashMap<Object, Object>();map.put("total", count);int size = list.size();
@RequestParam(defaultValue = "正常", required = false) String tbStatus,@RequestParam(required = false) String keyword,@RequestParam(defaultValue = "test_id", required = false) String order,@RequestParam(defaultValue = "desc", required = false) String desc) {Object data = null;String statusMsg = "";int statusCode = 200;LinkedHashMap<String, String> condition = new LinkedHashMap<String, String>();/** if (tbStatus != null && tbStatus.length() > 0) { condition.put("tb_status='"* + tbStatus + "'", "and"); }*/if (keyword != null && keyword.length() > 0) {StringBuffer buf = new StringBuffer();buf.append("(");buf.append("test_name like '%").append(keyword).append("%'");buf.append(" or ");buf.append("info like '%").append(keyword).append("%'");buf.append(" or ");buf.append("other like '%").append(keyword).append("%'");buf.append(")");condition.put(buf.toString(), "and");
public WebResponse addMusicCollect(HttpServletRequest request, HttpServletResponse response, HttpSession session,@RequestParam(required = false) int song_id, @RequestParam(required = false) String user_name,@RequestParam(required = false) String user_password, @RequestParam(required = false) String songName) {WebResponse webResponse = new WebResponse();MusicLink musicLink = new MusicLink();User user = new User();System.out.println("歌曲id:" + song_id + " 用户名:" + user_name + " 户用密码:" + user_password);Object data = null;String statusMsg = "";int statusCode = 200;String user_Id = null;try {user_Id = musicLinkService2.getUserId(user_name, user_password);} catch (Exception e) {}int userId = 0;try {// 判断字符串是否是数字,并且抛出异常boolean NotisNum = (user_Id.equals("null"));// System.out.println(NotisNum);if (!NotisNum) {userId = Integer.parseInt(user_Id);
return webResponse.getWebResponse(statusCode, statusMsg, data);} else {statusCode = 200;webResponse.setStatusCode(statusCode);System.out.println("状态码:" + webResponse.getStatusCode());System.out.println("登录成功了");System.out.println();return webResponse.getWebResponseUserId(statusCode, statusMsg, data, userId);}}// 更改密码 更改密码 更改密码@RequestMapping(value = "/resetUserPassword", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")@ResponseBodypublic WebResponse resetUserPassword(HttpServletRequest request, HttpSession session) {
适用
课程设计,大作业,毕业设计,项目练习,学习演示等