• SSH实现简单在线听音乐收藏管理系统


    作者主页:夜未央5788

     简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文末获取源码

    项目介绍

    项目分为管理员与普通用户两种角色,

    管理员角色包含以下功能:

    管理员登录,用户管理,歌曲管理等功能。

    用户角色包含以下功能:

    按分类查看,添加歌单,用户登录等功能。

    演示视频:点此查看

    由于本程序规模不大,可供课程设计,毕业设计学习演示之用


    更多项目源码,请到“源码空间站”,地址:http://www.shuyue.fun/

    环境需要

    1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
    3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
    4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

    5.数据库:MySql 5.7版本;

    6.是否Maven项目:否;

    技术栈

    1. 后端:Spring SpringMVC Hibernate

    2. 前端:JSP+Javascript+css+jQuery

    使用说明

    1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
    2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
    若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
    3. 将项目中database-config.properties配置文件中的数据库配置改为自己的配置;

    4. 运行项目,输入http://localhost:8080/ssh_zxmusicsite/ 登录

    运行截图

    普通用户角色

     

     

    管理员角色

     

     

     

    相关代码 

    AddUserMusicList

    1. /**
    2. * Servlet implementation class AddUserMusicList
    3. */
    4. @WebServlet("/AddUserMusicList")
    5. public class AddUserMusicList extends HttpServlet {
    6. private static final long serialVersionUID = 1L;
    7. private IUserMusicListDao userMusicListDao;
    8. /**
    9. * @see HttpServlet#HttpServlet()
    10. */
    11. @Override
    12. public void init(ServletConfig config) throws ServletException {
    13. // TODO Auto-generated method stub
    14. super.init(config);
    15. ServletContext servletContext = this.getServletContext();
    16. WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    17. userMusicListDao = (IUserMusicListDao)ctx.getBean("userMusicListDao");
    18. }
    19. public IUserMusicListDao getUserMusicListDao() {
    20. return userMusicListDao;
    21. }
    22. public void setUserMusicListDao(IUserMusicListDao userMusicListDao) {
    23. this.userMusicListDao = userMusicListDao;
    24. }
    25. /**
    26. * @see HttpServlet#HttpServlet()
    27. */
    28. public AddUserMusicList() {
    29. super();
    30. // TODO Auto-generated constructor stub
    31. }
    32. /**
    33. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    34. */
    35. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    36. String userMusicListName=request.getParameter("userMusicListName");
    37. String userId=request.getParameter("userId");
    38. UserMusicList userMusicList=new UserMusicList();
    39. userMusicList.setName(userMusicListName);
    40. try {
    41. userMusicListDao.addUserMusicList(userMusicList,Integer.parseInt(userId));
    42. PrintWriter out=response.getWriter();
    43. out.write("1");
    44. } catch (Exception e) {
    45. // TODO Auto-generated catch block
    46. e.printStackTrace();
    47. }
    48. }
    49. /**
    50. * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    51. */
    52. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    53. // TODO Auto-generated method stub
    54. doGet(request, response);
    55. }
    56. }

    管理员登录

    1. /**
    2. * Servlet implementation class AdminLogin
    3. */
    4. @WebServlet("/AdminLogin")
    5. public class AdminLogin extends HttpServlet {
    6. private IAdminDao adminDao;
    7. @Override
    8. public void init(ServletConfig config) throws ServletException {
    9. // TODO Auto-generated method stub
    10. super.init(config);
    11. ServletContext servletContext = this.getServletContext();
    12. WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    13. adminDao = (IAdminDao)ctx.getBean("adminDao");
    14. }
    15. /**
    16. * @see HttpServlet#HttpServlet()
    17. */
    18. public AdminLogin() {
    19. super();
    20. // TODO Auto-generated constructor stub
    21. }
    22. /**
    23. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    24. */
    25. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    26. response.setCharacterEncoding("UTF-8");
    27. // IAdminDao adminDao = new AdminDao();
    28. String adminName = request.getParameter("mname");
    29. String adminPassword = request.getParameter("mpwd");
    30. Admin admin = adminDao.login(adminName);
    31. if(admin != null){
    32. if(admin.getAdminPassword().equals(adminPassword)){
    33. System.out.println("111111111111111");
    34. request.getSession().setAttribute("admin_1", admin);
    35. request.getRequestDispatcher("context.jsp").forward(request, response);
    36. return;
    37. }else{
    38. System.out.println("222222222222");
    39. request.setAttribute("msg", "密码错误");
    40. }
    41. }else{
    42. System.out.println("33333333333333");
    43. request.setAttribute("msg", "没有此管理员");
    44. }
    45. System.out.println(request.getParameter("mname"));
    46. System.out.println(request.getParameter("mpwd"));
    47. request.getRequestDispatcher("login.jsp").forward(request, response);
    48. }
    49. /**
    50. * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    51. */
    52. protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    53. // TODO Auto-generated method stub
    54. doGet(request, response);
    55. }
    56. public IAdminDao getAdminDao() {
    57. return adminDao;
    58. }
    59. public void setAdminDao(IAdminDao adminDao) {
    60. this.adminDao = adminDao;
    61. }
    62. }

    收集音乐

    1. /**
    2. * Servlet implementation class CollectionMusic
    3. */
    4. @WebServlet("/CollectionMusic")
    5. public class CollectionMusic extends HttpServlet {
    6. private static final long serialVersionUID = 1L;
    7. private IUserMusicListDao userMusicListDao;
    8. /**
    9. * @see HttpServlet#HttpServlet()
    10. */
    11. @Override
    12. public void init(ServletConfig config) throws ServletException {
    13. // TODO Auto-generated method stub
    14. super.init(config);
    15. ServletContext servletContext = this.getServletContext();
    16. WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    17. userMusicListDao = (IUserMusicListDao)ctx.getBean("userMusicListDao");
    18. }
    19. public IUserMusicListDao getUserMusicListDao() {
    20. return userMusicListDao;
    21. }
    22. public void setUserMusicListDao(IUserMusicListDao userMusicListDao) {
    23. this.userMusicListDao = userMusicListDao;
    24. }
    25. /**
    26. * @see HttpServlet#HttpServlet()
    27. */
    28. public CollectionMusic() {
    29. super();
    30. // TODO Auto-generated constructor stub
    31. }
    32. /**
    33. * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    34. */
    35. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    36. String musicID=request.getParameter("musicID");
    37. String musicListID=request.getParameter("musicListID");
    38. PrintWriter out=response.getWriter();
    39. try {
    40. boolean b=userMusicListDao.getMusicbylist(Integer.parseInt(musicID), Integer.parseInt(musicListID));
    41. if(!b){
    42. userMusicListDao.CollectionMusic(Integer.parseInt(musicID), Integer.parseInt(musicListID));
    43. out.write("1");
    44. }else{
    45. out.write("0");
    46. }
    47. //userMusicListDao.CollectionMusic(5, 1);
    48. } catch (Exception e) {
    49. // TODO Auto-generated catch block
    50. e.printStackTrace();
    51. }
    52. }

    如果也想学习本系统,下面领取。回复:113ssh

  • 相关阅读:
    【Java面试】Spring 里面的事务和分布式事务的使用如何区分,以及这两个事务之间有什么关联?
    C++对象拷贝
    【毕业季】总结过去,展望未来
    【Netty】1-3. Netty急速入门 - 编码实现(java)
    大数据毕设选题 - 深度学习火焰识别检测系统(python YOLO)
    第七章,相似矩阵及其应用,5-正定二次型
    JavaWeb的Servlet项目导入Eclipse以及配置Mysql等通用教程
    高级前端进阶(五)
    深入浅出理解分布式一致性Paxos算法
    Linux命令(103)之du
  • 原文地址:https://blog.csdn.net/hanyunlong1989/article/details/125632709