Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

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

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report