日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

中软国际第十天

發布時間:2024/1/18 45 豆豆
生活随笔 收集整理的這篇文章主要介紹了 中软国际第十天 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

中軟國際第十天

基于SpringBoot的增刪改查

TypeController

package com.zr.web;import com.zr.po.Type; import com.zr.service.ITypeService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.web.PageableDefault; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping;@Controller @RequestMapping("/admin/types") public class TypeController {@Autowiredprivate ITypeService typeService;@GetMappingpublic String list(@PageableDefault(size = 5,sort ={"id"},direction = Sort.Direction.DESC)Pageable pageable, Model model){Page<Type> page=typeService.listType(pageable);model.addAttribute("page",page);return "admin/types";}@GetMapping("{id}/delete")public String delete(@PathVariable Long id){typeService.deleteTypeById(id);return "redirect:/admin/types";}@GetMapping("input")public String input(){return "admin/types-input";}@PostMapping("add")public String add(Type type){typeService.addType(type);return "redirect:/admin/types";}@GetMapping("{id}/toUpdate")public String toUpdate(@PathVariable Long id,Model model){Type type= typeService.getType(id);model.addAttribute("type",type);return "admin/types-input";}@PostMapping("update/{id}")public String update(Type type, @PathVariable Long id){typeService.update(id,type);return "redirect:/admin/types";}

LoginController

package com.zr.web;import com.zr.po.User; import com.zr.service.IUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.mvc.support.RedirectAttributes;import javax.servlet.http.HttpSession;@Controller @RequestMapping("/admin") public class LoginController {@Autowiredprivate IUserService userService;@GetMappingpublic String toLogin(){return "admin/login";}@PostMapping("/login")public String login(String username, String password, HttpSession session, RedirectAttributes redirectAttributes){User user = userService.checkUser(username, password);if (user!=null){session.setAttribute("user",user);return "admin/index";}else {redirectAttributes.addFlashAttribute("message","用戶名和密碼錯誤");return "redirect:/admin";}}@GetMapping("/logout")public String logout(HttpSession session){session.removeAttribute("user");return "admin/login";} }

types-input.html

<!DOCTYPE html> <html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"> <head th:replace="admin/_fragments :: head(~{::title})"><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>分類新增</title><link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css"><link rel="stylesheet" href="../../static/lib/editormd/css/editormd.min.css"><link rel="stylesheet" href="../../static/css/me.css"> </head> <body><!--導航--><nav th:replace="admin/_fragments :: menu(2)" class="ui inverted attached segment m-padded-tb-mini m-shadow-small" ><div class="ui container"><div class="ui inverted secondary stackable menu"><h2 class="ui teal header item">管理后臺</h2><a href="#" class="active m-item item m-mobile-hide"><i class="mini home icon"></i>博客</a><a href="#" class=" m-item item m-mobile-hide"><i class="mini idea icon"></i>分類</a><a href="#" class="m-item item m-mobile-hide"><i class="mini tags icon"></i>標簽</a><div class="right m-item m-mobile-hide menu"><div class="ui dropdown item"><div class="text"><img class="ui avatar image" src="https://unsplash.it/100/100?image=1005">李仁密</div><i class="dropdown icon"></i><div class="menu"><a href="#" class="item">注銷</a></div></div></div></div></div><a href="#" class="ui menu toggle black icon button m-right-top m-mobile-show"><i class="sidebar icon"></i></a></nav><div class="ui attached pointing menu"><div class="ui container"><div class="right menu"><a href="#" th:href="@{/admin/types/input}" class="active item">新增</a><a href="#" th:href="@{/admin/types}" class="teal item">列表</a></div></div></div><!--中間內容--><div class="m-container-small m-padded-tb-big"><div class="ui container"><form action="#" method="post" th:action="*{id}==null ? @{/admin/types/add} : @{/admin/types/update/{id}(id=*{id})}" class="ui form"><input type="hidden" name="id" th:value="*{id}"><div class=" field"><div class="ui left labeled input"><label class="ui teal basic label">名稱</label><input type="text" name="name" placeholder="分類名稱" th:value="*{name}" ></div></div><div class="ui error message"></div><div class="ui right aligned container"><button type="button" class="ui button" onclick="window.history.go(-1)" >返回</button><button class="ui teal submit button">提交</button></div></form></div></div><br><br><br><br><br><br><br><br><!--底部footer--><footer th:replace="admin/_fragments :: footer" class="ui inverted vertical segment m-padded-tb-massive"><div class="ui center aligned container"><div class="ui inverted divided stackable grid"><div class="three wide column"><div class="ui inverted link list"><div class="item"><img src="../../static/images/wechat.jpg" class="ui rounded image" alt="" style="width: 110px"></div></div></div><div class="three wide column"><h4 class="ui inverted header m-text-thin m-text-spaced " >最新博客</h4><div class="ui inverted link list"><a href="#" class="item m-text-thin">用戶故事(User Story)</a><a href="#" class="item m-text-thin">用戶故事(User Story)</a><a href="#" class="item m-text-thin">用戶故事(User Story)</a></div></div><div class="three wide column"><h4 class="ui inverted header m-text-thin m-text-spaced ">聯系我</h4><div class="ui inverted link list"><a href="#" class="item m-text-thin">Email:liuhuali@163.com</a><a href="#" class="item m-text-thin">QQ:liuhuali</a></div></div><div class="seven wide column"><h4 class="ui inverted header m-text-thin m-text-spaced ">Blog</h4><p class="m-text-thin m-text-spaced m-opacity-mini">這是我的個人博客、會分享關于編程、寫作、思考相關的任何內容,希望可以給來到這兒的人有所幫助...</p></div></div><div class="ui inverted section divider"></div><p class="m-text-thin m-text-spaced m-opacity-tiny">Copyright ? 2016 - 2017 liuhuali Designed by liuhuali</p></div></footer><script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script><script src="../../static/lib/editormd/editormd.min.js" th:src="@{/lib/editormd/editormd.min.js}"></script><script>$('.menu.toggle').click(function () {$('.m-item').toggleClass('m-mobile-hide');});$('.ui.dropdown').dropdown({on : 'hover'});$('.ui.form').form({fields : {title : {identifier: 'name',rules: [{type : 'empty',prompt: '請輸入分類名稱'}]}}});</script> </body> </html>

很充實,感謝劉老師!

總結

以上是生活随笔為你收集整理的中软国际第十天的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。