发布时间:2023-12-08 11:00
今天给大家分享一个基于SSM框架的音乐视频网站,其包含音乐播放,视频播放,音视频管理等模块,下面开始介绍其详细内容。
基础框架:SSM SpringMVC+Spring+Mybatis
前端框架:Bootstrap
数据库:MySQL 5.7
开发软件及环境:eclipse JDK 1.8 Tomcat 8.0
前台功能
音乐列表(音乐播放),类型列表,音乐热度排行榜,歌手列表,视频列表,登录注册
后台功能
用户管理,视频管理,音乐管理
下面以后台音乐管理为例介绍其实现流程
首先是配置文件:
applicationContext.xml
<beans xmlns=\"http://www.springframework.org/schema/beans\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:p=\"http://www.springframework.org/schema/p\"
xmlns:context=\"http://www.springframework.org/schema/context\" xmlns:tx=\"http://www.springframework.org/schema/tx\"
xsi:schemaLocation=\"
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd\">
<context:component-scan base-package=\"dao,service.impl\"/>
<bean id=\"dataSource\" class=\"org.apache.commons.dbcp.BasicDataSource\">
<property name=\"driverClassName\" value=\"com.mysql.jdbc.Driver\">property>
<property name=\"url\" value=\"jdbc:mysql://localhost:3306/music\">property>
<property name=\"username\" value=\"root\">property>
<property name=\"password\" value=\"px980305\">property>
bean>
<bean id=\"sqlSessionFactory\" class=\"org.mybatis.spring.SqlSessionFactoryBean\">
<property name=\"dataSource\" ref=\"dataSource\">property>
<property name=\"mapperLocations\" value=\"classpath:mapper/*.xml\"/>
bean>
<bean class=\"org.mybatis.spring.mapper.MapperScannerConfigurer\">
<property name=\"basePackage\" value=\"dao\">property>
bean>
beans>
springmvc-servlet.xml
<beans xmlns=\"http://www.springframework.org/schema/beans\"
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:context=\"http://www.springframework.org/schema/context\"
xmlns:mvc=\"http://www.springframework.org/schema/mvc\"
xsi:schemaLocation=\"http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd\">
<context:component-scan base-package=\"controller\"/>
<bean class=\"org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter\">
<property name=\"messageConverters\">
<list>
<bean class=\"org.springframework.http.converter.json.MappingJacksonHttpMessageConverter\">bean>
list>
property>
bean>
<bean class=\"org.springframework.web.servlet.handler.SimpleMappingExceptionResolver\">
<property name=\"defaultErrorView\" value=\"404\">property>
<property name=\"exceptionAttribute\" value=\"ex\">property>
bean>
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path=\"/*Manager.html\"/>
<bean class=\"interceptor.AdminInterceptor\">bean>
mvc:interceptor>
mvc:interceptors>
<bean id=\"viewResovler\"
class=\"org.springframework.web.servlet.view.UrlBasedViewResolver\">
<property name=\"prefix\" value=\"/WEB-INF/jsp/\"/>
<property name=\"suffix\" value=\".jsp\"/>
<property name=\"viewClass\" value=\"org.springframework.web.servlet.view.JstlView\"/>
bean>
<bean id=\"multipartResolver\" class=\"org.springframework.web.multipart.commons.CommonsMultipartResolver\">
<property name=\"defaultEncoding\" value=\"utf-8\">property>
<property name=\"maxUploadSize\" value=\"10485760000\">property>
<property name=\"maxInMemorySize\" value=\"40960\">property>
bean>
beans>
web.xml 伪装
<servlet>
<servlet-name>springmvcservlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServletservlet-class>
servlet>
<servlet-mapping>
<servlet-name>springmvcservlet-name>
<url-pattern>*.htmlurl-pattern>
servlet-mapping>
以上便是配置文件的内容,下面开始介绍其实现流程
在musicManager中调用业务层,执行持久层数据库操作并将数据封装为json的方式返还
@RequestMapping(\"musicManager\")
public String getAllSong(Model model,PrintWriter out){
List<Map<String, Object>> list=musicService.selectAllSong();
JSONArray jArray = JSONArray.fromObject(list);
model.addAttribute(\"list\",jArray);
System.out.println(jArray);
return \"musicManager\";
}
Service的具体实现,去调用持久层方法
@Override
public List<Map<String, Object>> selectAllSong() {
return dao.selectAllSong();
}
Mapper实现
<select id=\"selectAllSong\" resultType=\"hashmap\">
SELECT * from music join singer on music.singerId = singer.singerId join
musictype on music.musicTypeId=musictype.musicTypeId ORDER BY time DESC
select>
至此便将数据获取到了,然后经过层层返还
,在jsp页面中显示:
<c:if test=\"${not empty list }\">
<c:forEach var=\"m\" items=\"${list }\">
<tr> <td>${m.musicId }td> <td>${m.musicName }td> <td>${m.musicPhotoURL }td> <td>${m.musicHot }td> <td>${m.lyricURL }td> <td>${m.songURL }td> <td>${m.singerName }td> <td>${m.musicTypeName }td>
tr>
c:forEach>
至此,查询所有音乐便完成了。
以上便是该项目的部分内容。
[自用代码]基于python的遥感影像传统分割方法(直方图双峰法,阈值分割法,模糊C均值法,超像素分割法,K-means,snake)
基于eBPF的云原生可观测性开源项目Kindling之eBPF基础设施库技术选型
HaaS轻应用(Python):基于HaaS-AI的文字识别
文件上传漏洞靶场upload-labs学习(pass16-pass21)
Cobalt Strike: 解密混淆过的流量-Part 4
程序员离职后收到前东家2400元,反手被告违反竞业协议赔35万
Jetson Nano | darknet (yolov3.4-tiny)摄像头实时检测
linux怎么取消文件隐藏命令,Linux基础命令:显示隐藏的文件
山石网科Hillstone防火墙基础网络配置_WebUI(最新版)
mysql数据库sql审核_Yearning 介绍(SQL审核平台)