Get the App
SLTechnology News&Howtos  ›  Development  › 

How to read video list and play video by SpringBoot+thymeleaf

Shulou Source: shulou.com Published: 2022-05-31 21:29:29 10月05日 Update

This article mainly introduces SpringBoot+thymeleaf how to read the video list and play video related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that after reading this SpringBoot+thymeleaf how to read the video list and play the video function article will have a harvest, let's take a look.

Effect.

Springboot plays video

Implementation process back-end program example

1. Controller layer example

When returning database data, PageInfo in pagehelp is used. In order to expand the paging function later, the return value type should be entity class Video.

Package com.dvms.controller;/* * filename: VideoController * creator: CJW * creation time: 16:40 on 2022-4-14 * description: TODO * / import com.dvms.entity.Video;import com.dvms.service.ParamoduleService;import com.github.pagehelper.PageInfo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.ui.Model;import org.springframework.web.bind.annotation.RequestMapping;@Controllerpublic class VideoController {@ Autowired private ParamoduleService paramoduleService / / find the record @ RequestMapping ("/ angle/findvideoRecord") public String findvideorecords (Model model) {System.out.println (paramoduleService.findvideorecord ()); PageInfo videoRecord = new PageInfo (paramoduleService.findvideorecord ()); model.addAttribute ("videorecord", videoRecord); return "angle/videorecord" Find out the video address @ RequestMapping ("/ angle/findvideo") public String findvideo (String id, String filenamev, Model model) {System.out.println (id); String videopath = paramoduleService.findvideo (id); System.out.println (videopath); model.addAttribute ("videourl", videopath); model.addAttribute ("videoname", filenamev); return "angle/videoshow";}

2. Service layer

Package com.dvms.service;import com.dvms.entity.Record;import com.dvms.entity.Video;import java.util.List;import java.util.Map;/* * File name: ParamoduleService * creator: CJW * creation time: 10:54 on 2022-1-15 * description: TODO * / public interface ParamoduleService {String findvideo (String id); List findvideorecord ();}

3. ServiceImpl layer

Package com.dvms.service.Impl;import com.dvms.dao.ParamoduleDao;import com.dvms.entity.Record;import com.dvms.entity.Video;import com.dvms.service.ParamoduleService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.List;import java.util.Map / * * File name: ParamoduleServiceImpl * creator: CJW * creation time: 10:55 on 2022-1-15 * description: TODO * / @ Servicepublic class ParamoduleServiceImpl implements ParamoduleService {@ Autowired private ParamoduleDao paramoduleDao; / / find out the video file address @ Override public String findvideo (String id) {return paramoduleDao.findvideo (id);} / find out the video record @ Override public List findvideorecord () {return paramoduleDao.findvideorecord ();}}

4. Dao (mapper) layer

Package com.dvms.dao;import com.dvms.entity.Record;import com.dvms.entity.Video;import org.springframework.stereotype.Repository;import java.util.List;import java.util.Map;/* * File name: ParamoduleDao * creator: CJW * creation time: 10:52 on 2022-1-15 * description: TODO * / @ Repositorypublic interface ParamoduleDao {String findvideo (String id); List findvideorecord ();}

4. Entity (pojo) layer

Package com.dvms.entity;/* * filename: Video * creator: CJW * creation time: 16:17 on 2022-4-14 * description: TODO * / import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import lombok.ToString;import lombok.experimental.Accessors;@Data@ToString@AllArgsConstructor@NoArgsConstructor@Accessors (chain = true) / / chain call public class Video {private String id; private String filename; private String filepath;}

5. DaoMapper.xml

Select filepath from video where id=# {id} select id,filename,filepath from video

6. Video database table structure

Front-end program example

The front end needs to introduce thymeleaf, bootstrap and so on.

1. Videorecord.html

Video management Video recording ID Video file name Operation Play and download

2. Videoshow.html

Video playback example The video is currently played: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Your browser does not support HTML5 video tags. XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX About "how to read the video list and play it in SpringBoot+thymeleaf?" This is the end of the article "Video function". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "how to read the video list and play video" in SpringBoot+thymeleaf. If you want to learn more, you are welcome to follow the industry information channel.

Tags: Video file name function creator time example data knowledge content front end address database program article value writing entity simple operation effect Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi NVidia Shulou Technology Shulou Tech Info macOS