作者主页:夜未央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/ 登录
- /**
- * Servlet implementation class AddUserMusicList
- */
- @WebServlet("/AddUserMusicList")
- public class AddUserMusicList extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private IUserMusicListDao userMusicListDao;
- /**
- * @see HttpServlet#HttpServlet()
- */
- @Override
- public void init(ServletConfig config) throws ServletException {
- // TODO Auto-generated method stub
- super.init(config);
-
- ServletContext servletContext = this.getServletContext();
-
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
-
- userMusicListDao = (IUserMusicListDao)ctx.getBean("userMusicListDao");
- }
- public IUserMusicListDao getUserMusicListDao() {
- return userMusicListDao;
- }
- public void setUserMusicListDao(IUserMusicListDao userMusicListDao) {
- this.userMusicListDao = userMusicListDao;
- }
- /**
- * @see HttpServlet#HttpServlet()
- */
- public AddUserMusicList() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String userMusicListName=request.getParameter("userMusicListName");
- String userId=request.getParameter("userId");
- UserMusicList userMusicList=new UserMusicList();
- userMusicList.setName(userMusicListName);
- try {
- userMusicListDao.addUserMusicList(userMusicList,Integer.parseInt(userId));
- PrintWriter out=response.getWriter();
- out.write("1");
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
- * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- doGet(request, response);
- }
-
- }
- /**
- * Servlet implementation class AdminLogin
- */
- @WebServlet("/AdminLogin")
- public class AdminLogin extends HttpServlet {
-
-
- private IAdminDao adminDao;
-
- @Override
- public void init(ServletConfig config) throws ServletException {
- // TODO Auto-generated method stub
- super.init(config);
-
- ServletContext servletContext = this.getServletContext();
-
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
-
- adminDao = (IAdminDao)ctx.getBean("adminDao");
- }
-
- /**
- * @see HttpServlet#HttpServlet()
- */
- public AdminLogin() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
- response.setCharacterEncoding("UTF-8");
-
- // IAdminDao adminDao = new AdminDao();
-
- String adminName = request.getParameter("mname");
-
- String adminPassword = request.getParameter("mpwd");
-
- Admin admin = adminDao.login(adminName);
- if(admin != null){
-
- if(admin.getAdminPassword().equals(adminPassword)){
- System.out.println("111111111111111");
- request.getSession().setAttribute("admin_1", admin);
-
- request.getRequestDispatcher("context.jsp").forward(request, response);
-
- return;
- }else{
- System.out.println("222222222222");
- request.setAttribute("msg", "密码错误");
- }
- }else{
- System.out.println("33333333333333");
- request.setAttribute("msg", "没有此管理员");
- }
-
- System.out.println(request.getParameter("mname"));
-
- System.out.println(request.getParameter("mpwd"));
-
- request.getRequestDispatcher("login.jsp").forward(request, response);
- }
-
- /**
- * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- // TODO Auto-generated method stub
- doGet(request, response);
- }
-
- public IAdminDao getAdminDao() {
- return adminDao;
- }
-
- public void setAdminDao(IAdminDao adminDao) {
- this.adminDao = adminDao;
- }
-
- }
- /**
- * Servlet implementation class CollectionMusic
- */
- @WebServlet("/CollectionMusic")
- public class CollectionMusic extends HttpServlet {
- private static final long serialVersionUID = 1L;
- private IUserMusicListDao userMusicListDao;
- /**
- * @see HttpServlet#HttpServlet()
- */
- @Override
- public void init(ServletConfig config) throws ServletException {
- // TODO Auto-generated method stub
- super.init(config);
-
- ServletContext servletContext = this.getServletContext();
-
- WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext);
-
- userMusicListDao = (IUserMusicListDao)ctx.getBean("userMusicListDao");
- }
- public IUserMusicListDao getUserMusicListDao() {
- return userMusicListDao;
- }
- public void setUserMusicListDao(IUserMusicListDao userMusicListDao) {
- this.userMusicListDao = userMusicListDao;
- }
- /**
- * @see HttpServlet#HttpServlet()
- */
- public CollectionMusic() {
- super();
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
- */
- protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
- String musicID=request.getParameter("musicID");
- String musicListID=request.getParameter("musicListID");
-
- PrintWriter out=response.getWriter();
-
-
- try {
-
- boolean b=userMusicListDao.getMusicbylist(Integer.parseInt(musicID), Integer.parseInt(musicListID));
-
-
- if(!b){
- userMusicListDao.CollectionMusic(Integer.parseInt(musicID), Integer.parseInt(musicListID));
- out.write("1");
- }else{
- out.write("0");
- }
-
-
- //userMusicListDao.CollectionMusic(5, 1);
-
-
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
如果也想学习本系统,下面领取。回复:113ssh