Project introduction

The system uses the framework of Spring+SpringMVC+MyBatis, and the database uses MySQL, which is divided into the following four modules:

  1. Login registration and user management

2. Resource management The administrator adds movie resources from the backend and assigns the information such as name, picture, duration, movie release time, score, director, actor, type, region, etc. After the release is successful, the backend and user page can view and play the movie. 3. While increasing the interaction and maintaining a good environment, comment management has built-in sensitive word filtering for user comments. 4. Collection management Users can add their favorite movies to the collection center for easy viewing at any time.

Project applicable group

Graduate students, or Java learners who need hands-on practice on a project

Development environment:

  1. jdk 8
  2. intellij idea
  3. Tomcat 8.5.40
  4. Mysql 5.7

Technology used:

  1. Spring+SpringMVC+MyBatis
  2. layui
  3. jsp

Project Access Address

Front-end access address

http://localhost:8090/index
Copy the code

Background access address

http://localhost:8090/admin/index
admin/admin
Copy the code

Project screenshots

  • Home page

  • Popular movie

  • The film details

  • Movie play

  • Back end – Sensitive words

  • Backend – Evaluation list

  • Backend – Favorites list

  • Back-end – User list

Database Configuration

  1. Database Configuration Information
# configuration file JDBC url = JDBC: mysql: / / localhost: 3306 / movies? characterEncoding=UTF-8 jdbc.driverClass=com.mysql.jdbc.Driver jdbc.username=root jdbc.password=root123Copy the code
  1. Database configuration loading
<? The XML version = "1.0" encoding = "utf-8"? > <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <! <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="location" value="classpath:pro.properties" /> </bean> <! Define the data source Bean --> <! -- Druid --> <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="driverClassName" value="${jdbc.driverClass}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> <! - registered SqlSessionFactoryBean - > < bean id = "sqlSessionFactory" class = "org. Mybatis. Spring. SqlSessionFactoryBean" > < property name="dataSource" ref="dataSource" /> <! <property name="mapperLocations" value="classpath*:com/lrfalse/dao/**/*.xml" /> <property name="configLocation" value="classpath:mybatis-config.xml"></property> </bean> <! -- DAO interface package name, Spring will automatically find below class -- > < bean class = "org. Mybatis. Spring. Mapper. MapperScannerConfigurer" > < property name = "basePackage" value="com.lrfalse.dao" /> <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" /> </bean> <! Transaction Manager, use JtaTransactionManager for global tx --> <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean> </beans>Copy the code
  1. For springMvc configuration
<? The XML version = "1.0" encoding = "utf-8"? > <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/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <! <context:component-scan base-package=" com.lrFalse "/> <! --> < MVC :annotation-driven /> <! < MVC :resources location="/resource/" mapping="/resource/**" /> <mvc:resources location="/" mapping="/**/*.js"/> <mvc:resources location="/" mapping="/**/*.css"/> <mvc:resources location="/" mapping="/**/*.mp4"/> <mvc:resources location="/assets/" mapping="/assets/**/*"/> <mvc:resources location="/3rd/" mapping="/assets/**/*"/> <mvc:resources location="/assets/pc" mapping="/assets/pc/**/*"/> <! - assembly Swagger configuration - > < bean class = "com.lrfalse.com mon. SwaggerConfig" / > <! -- Avoid AJAX execution in IE Returns a JSON download file -- > < bean id = "mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html; charset=UTF-8</value> </list> </property> </bean> <! - increase tkmybatis annotation dependence - > < bean class = "tk. Mybatis. Spring. Mapper. MapperScannerConfigurer" > < property name = "basePackage" value="com.lrfalse.dao"/> <property name="beanName" value="normal"/> </bean> <! -- Configure the view resolver, either explicitly or not. <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"  /> <property name="suffix" value=".jsp" /> </bean> <! -- Configuration file upload, if you do not use file upload can not configure, of course, if not, <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver"> <! Property name="defaultEncoding" value=" UTF-8 "/> <! <property name="maxUploadSize" value="10485760000" /> <! <property name="maxInMemorySize" value="40960" /> </bean> </beans>Copy the code
  1. The web.xml configuration
<? The XML version = "1.0" encoding = "utf-8"? > <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Xsi: schemaLocation = "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version = "3.1"  metadata-complete="true"> <display-name>Archetype Created Web Application</display-name> <welcome-file-list> <welcome-file>/index</welcome-file> </welcome-file-list> <! <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mybatis.xml</param-value> </context-param> <! -- encodingFilter --> <filter> <filter-name>encodingFilter</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <! - Spring listener - > < listener > < listener - class > org. Springframework. Web. Context. ContextLoaderListener < / listener - class > </listener> <! -- Prevent Spring memory overflow listener --> <listener> <listener-class>org.springframework.web.util.IntrospectorCleanupListener</listener-class> </listener> <session-config> <session-timeout>600</session-timeout> </session-config> <! -- Spring MVC servlet --> <servlet> <servlet-name>SpringMVC</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:spring-mvc.xml</param-value> </init-param> <load-on-startup>1</load-on-startup> <async-supported>true</async-supported> </servlet> <servlet-mapping> <servlet-name>SpringMVC</servlet-name> <! *. Do, *. Struts --> <url-pattern>/</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>/index.jsp</welcome-file> </welcome-file-list> <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> <url-pattern>*.css</url-pattern> <url-pattern>*.png</url-pattern> <url-pattern>/assets/*"</url-pattern> <url-pattern>/3rd/*</url-pattern> </servlet-mapping> </web-app>Copy the code

Business code

  1. The film’s front page
@GetMapping(value = {"index",""}) public ModelAndView index(ModelAndView mav, HttpSession session){ List<Movies> randomList=moviesService.randomMovies(); / / trailer movie List < Movies > the hotList. = moviesService findHotMovies (); / / popular movie List < Movies > newestList = moviesService. FindNewestList (); // List<Movies> indexNewestList=new ArrayList<>(); for(Movies movies:newestList){ List<MoviesType> moviesTypes=moviesTypeService.findListById(movies.getId()); movies.setMoviesTypes(moviesTypes); indexNewestList.add(movies); } List<Movies> recommendList; Person person=(Person) session.getAttribute("loginUser"); if(person! = null) {/ / if the login, view the collection type of film, recommendList = moviesService. FindRecommendList (person) getId ()); / / movie recommended} else {/ / if not login, query hits 10 film recommendList = moviesService. FindHotMovies (); } mav.addObject("randomList",randomList); mav.addObject("hotList",hotList); mav.addObject("newestList",newestList); mav.addObject("recommendList",recommendList); mav.setViewName("pc/index"); return mav; } // front-end JSP < HTML lang="en"> <head> <meta charset=" utF-8 "> </title> <meta name="keywords" content=""> <meta name="description" content=""> <script SRC = "${pageContext. Request. ContextPath} / assets/PC/js/jquery - 1.11.3. Min. Js" > < / script > < script src="${pageContext.request.contextPath}/assets/pc/js/index.js"></script> <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/pc/css/index.css"> </head> <body> <jsp:include page="head.jsp"/> <div Class ="gg"> < p style =" margin-bottom: 0px; margin-bottom: 0px; </div> <div class="out l"> <div class="hot"> <img src="${pageContext.request.contextPath}/assets/pc/images/ribbon.png" alt="HoT"> </div> <ul class="img "> <li> <a href="# "> <img src="${pageContext.request.contextPath}/assets/pc/images/1.jpg " alt=" "> </a> </li> <li> <a href="# "> <img src="${pageContext.request.contextPath}/assets/pc/images/2.jpg " alt=" "> </a> </li> <li> <a href="# "> <img src="${pageContext.request.contextPath}/assets/pc/images/3.jpg " alt=" "> </a> </li> <li> <a href="# "> <img src="${pageContext.request.contextPath}/assets/pc/images/4.jpg " alt=" "> </a> </li> <li> <a href="# "> <img src="${pageContext.request.contextPath}/assets/pc/images/5.jpg " alt=" "> </a> </li> </ul> <ul class="num " > </ul> <div  class="left btn "><</div> <div class="right btn right-btn">></div> </div> <div class="box-line"> <%-- <span> Random movie resources </span>--%> <span> Movie trailer </span> </div> <div class="menu"> <div class="menu_item"> <c:forEach items="${randomList}" var="randoms"> <div class="menu_item_img"> <a href="${pageContext.request.contextPath}/details/${randoms.id}"> <img src="${fn:substring(randoms.img, 0, "> <img SRC ="${fn:substring(randoms.img, fn:indexOf(randoms.img, ","); , "") + 1, fn: length (randoms. Img))}" Alt = "image" > < / a > < / div > < / c: forEach > < / div > < / div > < main > < div class = "main" > < div "Class =" main_title > < h3 > the latest movie < / h3 > < a href = "" > more > > < / a > < / div > < c: forEach items =" ${newestList} "var =" newest "> < div class="main_item"> <a class="main_item_img" href="${pageContext.request.contextPath}/details/${newest.id}"> <img class="main_item_img_tu" src="${fn:substring(newest.img, 0, fn:indexOf(newest.img, ", "))} "Alt =" image "> < img class =" main_item_ico "SRC =" ${pageContext. Request. ContextPath} / assets/PC/images/play - icon. PNG" Alt = "" > < span class =" cq "> super clear < / span > < / a > < div class =" main_item_title "> < h1 > < a href =" # "target =" _blank" Title = "${newest. Name}" > ${newest. Name} < / a > < em > - ${newest. Score} < / em > < / h1 > < div class = "main_item_title_lei" > type:  <c:forEach items="${newest.moviesTypes}" var="type" varStatus="index"> <c:if test="${index.index<=3}"> <a class="movietype" href="#">${type.typeName}</a> </c:if> </c:forEach> </div> </div> </div> </c:forEach> <div Class = "cl" > < / div > < / div > < div class = "right" > < div class = "right_title" > < h3 > popular movie < / h3 > < / div > < c: forEach items="${hotList}" var="hot" varStatus="index" > <div class="list-group"> <a class="list-group-item" target="_blank" href="${pageContext.request.contextPath}/details/${hot.id}"> <span class="${index.index<3?'square-item-red':'square-item-blue'}">${index.index+1}</span> ${hot.name} </a> </div> < c: forEach > < / div > < / main > < div class = "main3" > < div class = "main3_title" > < h3 > movie recommend < / h3 > < a href = "" > more > > < / a > < / div > <c:forEach items="${recommendList}" var="recommend" varStatus="index"> <c:if test="${index.index<10}"> <div class="main3_item"> <div class="main3_item_img"> <a href="#"> <img src="${fn:substring(recommend.img, 0, fn:indexOf(recommend.img, ", "))} "Alt =" image "> < / a > < span class =" lg "> blue < / span > < div class =" main3_item_title "> < h1 > < a href =" # "target =" _blank" Title = "${how. Name}" > ${how. Name} < / a > < em > - ${how. Score} < / em > < / h1 > < div class = "main3_item_title_lei" > Type:  <c:forEach items="${recommend.moviesTypes}" var="type" varStatus="index"> <c:if test="${index.index<=3}"> <a class="movietype" href="#">${type.typeName}</a> </c:if> </c:forEach> </div> </div> </div> </div> </c:if> </c:forEach> </div> </body> </html>Copy the code
  1. The movie collection
@responseBody @postMapping (value = {"addCollection"}) @apiOperation (value = "addCollection",response = myCollection.class) public  Map addCollection( LikeMoviesDto likeMoviesDto){ Map map=ResponseMessage.success(); try{ MyCollection myCollection=new MyCollection(); BeanUtils.copyProperties(likeMoviesDto,myCollection); int result=myCollectionService.addCollection(myCollection); if(result==2){ myCollectionService.delCollection(myCollection); Map = responsemessage. success(" unbookmark successfully "); }else if(result==1){ Map data=new HashMap(); data.put("collectionId",myCollection.getId()); Map = responsemessage. success(" "); map.put("data",data); }else{map= responsemessage.fail (" fail to collect movies "); } }catch (Exception e){ e.printStackTrace(); Map = responsemessage. fail(" movie collection fails "); } return map; Function addCollection() {var user='${loginUser}'; If (null = = user | | user = = ' ') {layer. MSG (' please login first, {icon: 5}); }else{ var data={mId:${details.movies.id},uId:'${loginUser.id}'}; $.post('${pageContext.request.contextPath}/addCollection', data, function (data) { console.log(data); if (200 == data.returnCode) { layer.msg(data.returnMsg, {icon: 1, time: 1500}, function () { window.location.reload(); }); } else { layer.closeAll('loading'); layer.msg(data.returnMsg, {icon: 5}); } }, 'JSON'); }}Copy the code

Project follow-up

Other SSH, Springboot version of subsequent iterations update, continue to pay attention to

If there is any problem with the program, contact the program help