众所周知哔哩哔哩是大家喜爱的视频网站,网站的样式和内容都是非常不错的。今天就跟大家分享一个基于SSM框架的仿哔哩哔哩的系统,当然没法跟原网站比,这是简单的实现用户上传视频、观看视频、搜索视频、发送评论、发送弹幕等简单功能。

仿哔哩哔哩微信小程序(基于SSM的仿哔哩哔哩系统)(1)

仿哔哩哔哩微信小程序(基于SSM的仿哔哩哔哩系统)(2)

演示视频

首页代码展示

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>主页 - cilicili</title> <link rel="stylesheet" href="css/bootstrap.css"> <script src="js/libs/jquery-3.2.1.js"></script> <script src="js/utils/utils.js"></script> <script src="js/utils/ajaxBase.js"></script> <script src="js/utils/ajaxLogin.js"></script> <script src="js/utils/ajaxVideo.js"></script> <script src="js/utils/ajaxStatus.js"></script> <style> #banner { margin: auto; max-height: 400px; } .carousel-control .ltgt { margin: auto; width: 50px; height: 50px; border: 3px solid #ffffff; border-radius: 50%; font-size: 32px; position: relative; top: 45%; } .video-box { cursor: pointer; padding: 5px; } .video-box .info { text-shadow: 0 0 1px #aeaeae; } .video-box .info:hover { text-shadow: 0 0 1px #000000; } .video-box img { border-radius: 5px; } .video-box img:hover { box-shadow: #5e5e5e 1px 1px 5px; } </style> </head> <body> <div id="nav_vue"></div> <div class="container"> <div class="row clearfix"> <div class="col-md-12"> <div class="carousel slider" id="banner"> <ol class="carousel-indicators"> <li data-slide-to="0" data-target="#banner" class="active"></li> <li data-slide-to="1" data-target="#banner"></li> </ol> <div class="carousel-inner"> <div class="item active"> <img src="img/banner_0.png"/> </div> <div class="item"> <img src="img/banner_1.png"/> </div> <div data-slide="prev" href="#banner" class="left carousel-control" style="cursor: pointer"> <div class="ltgt"><</div> </div> <div data-slide="next" href="#banner" class="right carousel-control" style="cursor: pointer"> <div class="ltgt">></div> </div> </div> </div> </div> </div> </div> <div id="all_vue" class="container"> <div class="row clearfix"> <div class="col-md-12"> <hr> <h3>最新视频 </h3> <br> </div> </div> <template v-if="videosFound"> <div class="row clearfix"> <div class="col-md-12"> <template v-for="video in videos"> <div :class="['video-box', 'col-md-3', 'col-sm-4', 'col-xs-12', 'text-center']" :onclick="`window.location.href='video.htm?id=${video.id}'`"> <div class="row clearfix"> <div class="col-md-12 col-sm-12 col-xs-6"> <img :src="STORAGE_SERVER video.picUrl" width="210" height="140"> </div> <div class="info col-md-12 col-sm-12 col-xs-6"> <h4> {{`${video.title.substr(0, 10)}${video.title.length > 10 ? ' ...' : ''}`}} </h4> <p> {{video.countLike}} {{video.countPlay}} </p> <p> {{`${video.uploadUsername.substr(0, 10)}${video.uploadUsername.length > 10 ? ' ...' : ''}`}} </p> </div> </div> </div> </template> </div> </div> <div class="row clearfix"> <br><br> <div class="col-xs-2 col-sm-offset-2 text-right"> <button :class="['btn', 'btn-success', canBefore ? '' : 'disabled']" @click="before">上一页</button> </div> <div class="col-xs-6 col-xs-offset-1 col-sm-3 col-sm-offset-1 col-md-3 col-md-offset-1 col-lg-2"> <div class="input-group"> <input v-model="to" class="form-control" type="number" :max="pages" min="1"> <span class="input-group-addon"> / {{pages}} </span> <span class="input-group-btn"> <button class="btn btn-info" @click="go">前往</button> </span> </div> </div> <div class="col-xs-2 col-xs-offset-1"> <button :class="['btn', 'btn-primary', canNext ? '' : 'disabled']" @click="next">下一页</button> </div> </div> </template> <template v-else> <div class="row clearfix"> <div class="col-md-12 text-center"> <h1 class="text-center">没有更多视频</h1> <br> </div> </div> </template> </div> <div id="footer_vue"></div> <script src="js/libs/bootstrap.js"></script> <script src="js/libs/vue.js"></script> <script src="js/vue/nav_vue.js"></script> <script src="js/vue/footer_vue.js"></script> <script> let hasNextPage = false; let hasPreviousPage = false; let list = []; let pages = 0; const page = ajaxVideo.show(1); if (page.page !== undefined) { ({ page: { hasNextPage = false // 是否有后一页 , hasPreviousPage = false // 是否有前一页 , list = {} // 当前页的元素数组 , pages = 0 // 总页数 } } = page); } const all_vue = new Vue({ el: '#all_vue' , data: { STORAGE_SERVER: STORAGE_SERVER '/' , videos: list , videosFound: list.length !== 0 , offset: 1 , canNext: hasNextPage , canBefore: hasPreviousPage , pages , to: 1 }, methods: { next(e) { if (e.target.classList.contains("disabled")) { return; } this.offset ; const { page: { hasNextPage = false , hasPreviousPage = false , list = {} , pages = 0 } } = ajaxVideo.show(this.offset); this.videos = list; this.videosFound = this.videos.length !== 0; this.canNext = hasNextPage; this.canBefore = hasPreviousPage; this.to = this.offset; this.pages = pages; }, before(e) { if (e.target.classList.contains("disabled")) { return; } this.offset--; const { page: { hasNextPage = false , hasPreviousPage = false , list = {} , pages = 0 } } = ajaxVideo.show(this.offset); this.videos = list; this.videosFound = this.videos.length !== 0; this.canNext = hasNextPage; this.canBefore = hasPreviousPage; this.to = this.offset; this.pages = pages; }, go() { if (this.to < 1 || this.to > this.pages) { this.to = this.offset; return; } this.offset = this.to; const { page: { hasNextPage = false , hasPreviousPage = false , list = {} , pages = 0 } } = ajaxVideo.show(this.offset); this.videos = list; this.videosFound = this.videos.length !== 0; this.canNext = hasNextPage; this.canBefore = hasPreviousPage; this.pages = pages; } } }); </script> </body> </html>

什么是SSM框架

Spring

Spring就像是整个项目中装配bean的大工厂,在配置文件中可以指定使用特定的参数去调用实体类的构造方法来实例化对象。也可以称之为项目中的粘合剂。

Spring的核心思想是IoC(控制反转),即不再需要程序员去显式地`new`一个对象,而是让Spring框架帮你来完成这一切。

SpringMVC

SpringMVC在项目中拦截用户请求,它的核心Servlet即DispatcherServlet承担中介或是前台这样的职责,将用户请求通过HandlerMapping去匹配Controller,Controller就是具体对应请求所执行的操作。SpringMVC相当于SSH框架中struts。

mybatis

mybatis是对jdbc的封装,它让数据库底层操作变得透明。mybatis的操作都是围绕一个sqlSessionFactory实例展开的。mybatis通过配置文件关联到各实体类的Mapper文件,Mapper文件中配置了每个类对数据库所需进行的sql语句映射。在每次与数据库交互时,通过sqlSessionFactory拿到一个sqlSession,再执行sql命令。

获取源码请关注后私信“220”

,