当前位置: 首页 > news >正文

给公司做网站风险网络推广学校培训

给公司做网站风险,网络推广学校培训,网站建设分几种编程语言,中国四大互联网巨头更多的前端页面#xff08;如视频详情页、用户注册页等#xff09;。更复杂的业务逻辑#xff08;如视频评论、搜索功能等#xff09;。安全性和权限管理#xff08;如用户角色管理、权限控制等#xff09;。其他技术细节#xff08;如文件上传、分页查询等#xff09;…更多的前端页面如视频详情页、用户注册页等。更复杂的业务逻辑如视频评论、搜索功能等。安全性和权限管理如用户角色管理、权限控制等。其他技术细节如文件上传、分页查询等。 1. 视频详情页 创建一个视频详情页面显示视频的详细信息和评论。 videoView.html !DOCTYPE html html xmlns:thhttp://www.thymeleaf.org headtitleVideo Details/title /head body h1Video Details/h1 divh2 th:text${video.title}/h2p th:text${video.description}/pvideo width320 height240 controlssource th:src{${video.file_path}} typevideo/mp4Your browser does not support the video tag./videopCategory: span th:text${video.category.name}/span/ppUploaded by: span th:text${video.uploadUser.username}/span/ppUpload Time: span th:text${video.upload_time}/span/p /divh2Comments/h2 ulli th:eachcomment : ${video.comments}p th:text${comment.content}/ppBy: span th:text${comment.user.username}/span/ppAt: span th:text${comment.created_at}/span/p/li /ulform th:action{/video/comment/{id}(id${video.id})} methodpostlabelComment:/labeltextarea namecontent/textareabr/button typesubmitSubmit Comment/button /form /body /html2. 视频评论功能 在VideoController中添加处理评论的逻辑。 VideoController.java package com.video.controller;import com.video.entity.Comment; import com.video.entity.Video; import com.video.service.CommentService; import com.video.service.VideoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*;import java.util.List;Controller RequestMapping(/video) public class VideoController {Autowiredprivate VideoService videoService;Autowiredprivate CommentService commentService;GetMapping(/list)public String listVideos(Model model) {ListVideo videos videoService.getAllVideos();model.addAttribute(videos, videos);return videoList;}GetMapping(/view/{id})public String viewVideo(PathVariable(id) int id, Model model) {Video video videoService.getVideoById(id);video.setComments(commentService.getCommentsByVideoId(id));model.addAttribute(video, video);return videoView;}PostMapping(/comment/{id})public String addComment(PathVariable(id) int id, RequestParam(content) String content, Model model) {// 假设已经通过 session 获取到当前用户User currentUser (User) model.getAttribute(currentUser);Comment comment new Comment();comment.setContent(content);comment.setUser(currentUser);comment.setVideo(videoService.getVideoById(id));commentService.addComment(comment);return redirect:/video/view/ id;}// 其他方法... }3. 用户注册页 创建一个用户注册页面。 register.html !DOCTYPE html html xmlns:thhttp://www.thymeleaf.org headtitleRegister Page/title /head body h1Register/h1 form th:action{/user/register} methodpostlabelUsername:/labelinput typetext nameusername/br/labelPassword:/labelinput typepassword namepassword/br/labelEmail:/labelinput typeemail nameemail/br/labelPhone:/labelinput typetext namephone/br/button typesubmitRegister/button /form /body /html4. 文件上传功能 在VideoController中添加文件上传的逻辑。 VideoController.java package com.video.controller;import com.video.entity.Video; import com.video.service.VideoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile;import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.UUID;Controller RequestMapping(/video) public class VideoController {Autowiredprivate VideoService videoService;private final Path rootLocation Paths.get(uploads);PostMapping(/add)public String addVideo(ModelAttribute Video video, RequestParam(file) MultipartFile file) {try {// 保存文件到指定路径String uniqueFileName UUID.randomUUID().toString() _ file.getOriginalFilename();File dest new File(rootLocation.toString(), uniqueFileName);Files.copy(file.getInputStream(), dest.toPath());// 设置文件路径video.setFile_path(uniqueFileName);videoService.addVideo(video);} catch (IOException e) {e.printStackTrace();}return redirect:/video/list;}// 其他方法... }5. 分页查询 在VideoService中添加分页查询的功能。 VideoService.java package com.video.service;import com.video.entity.Video; import com.video.mapper.VideoMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;import java.util.List;Service public class VideoService {Autowiredprivate VideoMapper videoMapper;public ListVideo getAllVideos() {return videoMapper.findAll();}public ListVideo getVideosByPage(int page, int size) {int offset (page - 1) * size;return videoMapper.findVideosByPage(offset, size);}// 其他方法... }VideoMapper.java package com.video.mapper;import com.video.entity.Video; import org.apache.ibatis.annotations.*;import java.util.List;Mapper public interface VideoMapper {Select(SELECT * FROM video)ListVideo findAll();Select(SELECT * FROM video LIMIT #{offset}, #{size})ListVideo findVideosByPage(Param(offset) int offset, Param(size) int size);// 其他方法... }6. 视频列表页的分页功能 在videoList.html中添加分页功能。 videoList.html !DOCTYPE html html xmlns:thhttp://www.thymeleaf.org headtitleVideo List/title /head body h1Video List/h1 table border1trthID/ththTitle/ththDescription/ththFile Path/ththCategory/ththUpload User/ththUpload Time/ththActions/th/trtr th:eachvideo : ${videos}td th:text${video.id}/tdtd th:text${video.title}/tdtd th:text${video.description}/tdtd th:text${video.file_path}/tdtd th:text${video.category_id}/tdtd th:text${video.upload_user_id}/tdtd th:text${video.upload_time}/tdtda th:href{/video/view/{id}(id${video.id})}View/aa th:href{/video/edit/{id}(id${video.id})}Edit/aa th:href{/video/delete/{id}(id${video.id})}Delete/a/td/tr /tablediva th:if${currentPage 1} th:href{/video/list(page${currentPage - 1})}Previous/aa th:if${currentPage totalPages} th:href{/video/list(page${currentPage 1})}Next/a /diva href/video/addAdd New Video/a /body /html7. 视频列表控制器的分页支持 在VideoController中添加分页支持。 VideoController.java package com.video.controller;import com.video.entity.Video; import com.video.service.VideoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*;import java.util.List;Controller RequestMapping(/video) public class VideoController {Autowiredprivate VideoService videoService;GetMapping(/list)public String listVideos(RequestParam(defaultValue 1) int page, Model model) {int pageSize 10; // 每页显示的记录数ListVideo videos videoService.getVideosByPage(page, pageSize);int totalVideos videoService.getAllVideos().size();int totalPages (int) Math.ceil((double) totalVideos / pageSize);model.addAttribute(videos, videos);model.addAttribute(currentPage, page);model.addAttribute(totalPages, totalPages);return videoList;}// 其他方法... }以上是一些扩展功能的示例。如果有其他具体需求或问题请提供详细信息以便进一步帮助。
http://www.ho-use.cn/article/10812739.html

相关文章:

  • 网站插件代码下载商丘关键词优化推广
  • 珠海网站建设 amp 超凡科技中国移动积分兑换商城官方网站
  • 高端网站建站建造师人才网
  • 免费源码html网站免费网站模板 带后台
  • 无锡网站制作方案网页如何设计
  • 手机做任务网站北京响应式网站建设公司
  • 广州建设网站专家做网站录入和查询需求
  • 网站做三方登陆需要注册公司不做网站维护工资多少
  • excel网站做链接性价比高seo排名
  • 高端的家居行业网站开发通辽网站建设招聘
  • 深圳建设网站的公司新乡网站建设方案
  • 内蒙古赤峰市建设局网站wordpress页面样板
  • 石狮网站开发如何看一个网站是谁做的
  • 网站建设平台报价做衣服 网站
  • 网站轮播图上海门户网站建设
  • 银行门户网站开发python代码大全
  • 桂林医院网站建设注册域名和购买域名
  • 自己做网站怎么编代码全网响应式网站
  • 网站建设在开封找谁做wordpress菜单栏不显示不出来
  • 玉林住房和城乡建设局网站官网网站建设邯郸
  • 买域名后 怎么做网站南宁建设网站培训
  • 网站后台管理系统需求网站建设温江
  • 聊城网站案例六安公司做网站
  • 河北省建设工程协会网站比较有趣的网站
  • 个人怎么做电影相关的网站网站建设用模板好吗
  • 呼市做网站基于asp网站开发 论文
  • ui的设计网站百度文章收录提交入口
  • 浙江网站建设与维护书我爱我家二手房房源官网
  • 扬州市广陵区城乡建设局网站wordpress英文切换
  • 搭建个网站需要多少钱m导航网站如何做淘宝客