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

松江品划网络做网站无锡百度快照优化排名

松江品划网络做网站,无锡百度快照优化排名,珠海网站开发软件,餐馆餐饮装修设计1、引言 在Spring Boot中使用Thymeleaf模板引擎实现数据的添加、修改、查询和删除功能,通常步骤如下: 在Controller类中,定义处理HTTP请求的方法。创建Thymeleaf模板来处理表单的显示和数据的绑定。 2、用户数据添加 1、 在Controller类中…

1、引言

在Spring Boot中使用Thymeleaf模板引擎实现数据的添加、修改、查询和删除功能,通常步骤如下:

  1. 在Controller类中,定义处理HTTP请求的方法。
  2. 创建Thymeleaf模板来处理表单的显示和数据的绑定。

2、用户数据添加

1、 在Controller类中,定义处理HTTP请求的方法。

@Controller
@RequestMapping("/user")
public class UserController {@Autowiredprivate IUserService userService;@GetMapping("/addPage")public String addPage(){return "user/add";}@PostMapping("/add")@ResponseBodypublic String add(User user){boolean save = userService.save(user);return "success";}}

2、创建Thymeleaf 模板处理表单,模板存放在“templates/user/add.html”目录中

<!DOCTYPE html>  
<html lang="en">  
<head>  <meta charset="UTF-8">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>用户添加页面</title><!--style省略-->
</head>  
<body>  <div class="container">  <h2>用户添加</h2><form action="/user/add" method="post"><label for="name">姓名:</label>  <input type="text" id="name" name="name" required>  <label for="age">年龄:</label>  <input type="number" id="age" name="age" min="0" required>  <label for="email">邮箱:</label><input type="email" id="email" name="email" required>  <label for="introduce">介绍:</label><textarea id="introduce" name="introduce" rows="4" required></textarea><label for="phone">电话号码:</label>  <input type="tel" id="phone" name="phone" pattern="[0-9]{11}" placeholder="请输入11位数字" required>  <input type="submit" value="提交">  </form>  </div>  
</body>  
</html>

3、访问页面添加用户

http://127.0.0.1:8080/user/addPage 

在这里插入图片描述

3、用户数据修改

1、 在Controller类中,定义处理HTTP请求的方法。

@Controller
@RequestMapping("/user")
public class UserController {@Autowiredprivate IUserService userService;@GetMapping("/editPage")public String editPage(Long id,Model model){User user = userService.getById(id);model.addAttribute("user",user);return "user/edit";}@PostMapping("/edit")@ResponseBodypublic String edit(User user){userService.updateById(user);return "success";}
}

2、创建Thymeleaf 模板处理表单和绑定数据,模板存放在“templates/user/edit.html”目录中

<!DOCTYPE html>  
<html lang="en">  
<head>  <meta charset="UTF-8">  <meta name="viewport" content="width=device-width, initial-scale=1.0">  <title>用户修改页面</title>
<!--style省略-->
</head>  
<body>  <div class="container">  <h2>用户修改</h2><form action="/user/edit" method="post"><input type="hidden" name="id" th:value="${user.id}" ><label for="name">姓名:</label><input type="text" id="name" name="name" th:value="${user.name}" required><label for="age">年龄:</label>  <input type="number" id="age" name="age" min="0" th:value="${user.age}" required><label for="email">邮箱:</label>  <input type="email" id="email" name="email" th:value="${user.email}" required><label for="introduce">介绍:</label><textarea id="introduce" name="introduce" rows="4"  th:text="${user.introduce}" required></textarea><label for="phone">电话号码:</label>  <input type="tel" id="phone" name="phone" pattern="[0-9]{11}" th:value="${user.phone}" placeholder="请输入11位数字" required><input type="submit" value="提交">  </form>  </div>  
</body>  
</html>

3、访问页面修改用户

 http://127.0.0.1:8080/user/editPage?id=1

在这里插入图片描述

4、用户数据查询

Thymeleaf 实现数据动态渲染
Thymeleaf实现数据分页

5、用户数据删除

1、 在Controller类中,定义处理HTTP请求的方法。 这里删除完用户,重定向到列表页。

    @GetMapping("/delete")public String delete(Long id){userService.removeById(id);return "redirect:/user/list?pageNum=1";}

2、用户列表页模板添加删除按钮

<body>  <h1>简历列表</h1><ul class="resume-list" th:with="users=${userPageInfo.list}"><li class="resume-item" th:each="user:${users}"><a href="/user/detail"><h2 th:text="${user.name}">张三</h2><p th:text="${user.introduce}">软件工程师,具有5年工作经验,擅长Java和前端技术。</p><p th:text="${user.phone}">联系方式:123-4567-8901</p></a><a class="delete-button" th:href="'/user/delete?id='+${user.id}" >删除</a></li></ul>
<div class="page-foot"><a th:class="${pageNum==userPageInfo.pageNum?'active':''}" th:href="'/user/list?pageNum='+${pageNum}" th:each="pageNum:${userPageInfo.navigatepageNums}" >[[${pageNum}]]</a>
</div></body>

删除按钮样式

  .resume-item{display: flex;flex-direction: row;flex-wrap: nowrap;align-content: center;align-items: center;justify-content: space-between;}.delete-button{cursor: pointer;background: red;color: white;display: block;width: 50px;height: 30px;text-align: center;line-height: 30px;margin-right: 5%;border-radius: 5px;}

3、访问用户列表页删除用户

http://127.0.0.1:8080/user/list?pageNum=1

在这里插入图片描述


文章转载自:
http://dinncopodunk.stkw.cn
http://dinncogustaf.stkw.cn
http://dinncowashateria.stkw.cn
http://dinncoproenzyme.stkw.cn
http://dinncofloodlighting.stkw.cn
http://dinncosingularize.stkw.cn
http://dinncosay.stkw.cn
http://dinncocomte.stkw.cn
http://dinncokishm.stkw.cn
http://dinncotetracaine.stkw.cn
http://dinncosynthetase.stkw.cn
http://dinncorecoal.stkw.cn
http://dinncoahab.stkw.cn
http://dinncosandpaper.stkw.cn
http://dinncoscaffold.stkw.cn
http://dinncosubordinary.stkw.cn
http://dinncothither.stkw.cn
http://dinncoconsummation.stkw.cn
http://dinncoconfrontment.stkw.cn
http://dinncolimitless.stkw.cn
http://dinncoacetose.stkw.cn
http://dinncodietary.stkw.cn
http://dinncogasser.stkw.cn
http://dinncoshipbuilding.stkw.cn
http://dinncobullwhip.stkw.cn
http://dinncoinherent.stkw.cn
http://dinncoimmeasurably.stkw.cn
http://dinncogonfanon.stkw.cn
http://dinncoplanchette.stkw.cn
http://dinncoarenulous.stkw.cn
http://dinncocornichon.stkw.cn
http://dinncoaccusative.stkw.cn
http://dinncovisional.stkw.cn
http://dinncocliffy.stkw.cn
http://dinncowaffle.stkw.cn
http://dinncobajri.stkw.cn
http://dinncodrawbridge.stkw.cn
http://dinncoantidepressant.stkw.cn
http://dinncofloriferous.stkw.cn
http://dinncohowl.stkw.cn
http://dinncohemstitch.stkw.cn
http://dinncosometime.stkw.cn
http://dinncogermen.stkw.cn
http://dinncoclubbed.stkw.cn
http://dinncorockfish.stkw.cn
http://dinncojerkiness.stkw.cn
http://dinncoprotectingly.stkw.cn
http://dinncomastectomy.stkw.cn
http://dinncostraitjacket.stkw.cn
http://dinncosupermarketeer.stkw.cn
http://dinncopunctually.stkw.cn
http://dinncofootscraper.stkw.cn
http://dinncobant.stkw.cn
http://dinncostaphylococcus.stkw.cn
http://dinncosparry.stkw.cn
http://dinncorumor.stkw.cn
http://dinncoconversance.stkw.cn
http://dinncoginzo.stkw.cn
http://dinncoundernourished.stkw.cn
http://dinncochopsocky.stkw.cn
http://dinncoanourous.stkw.cn
http://dinncothan.stkw.cn
http://dinncomisarticulation.stkw.cn
http://dinncoalone.stkw.cn
http://dinncoobserver.stkw.cn
http://dinncocoextension.stkw.cn
http://dinncoany.stkw.cn
http://dinncoimmodest.stkw.cn
http://dinncocalcrete.stkw.cn
http://dinncomelphalan.stkw.cn
http://dinncotrapezius.stkw.cn
http://dinncoconvector.stkw.cn
http://dinncofawn.stkw.cn
http://dinncohackie.stkw.cn
http://dinncogravettian.stkw.cn
http://dinncofasciculus.stkw.cn
http://dinncomodom.stkw.cn
http://dinncobraillewriter.stkw.cn
http://dinncodyslexia.stkw.cn
http://dinncoloris.stkw.cn
http://dinncoprecondemn.stkw.cn
http://dinncopitcher.stkw.cn
http://dinncoconglomeritic.stkw.cn
http://dinncoradicalism.stkw.cn
http://dinncojeweler.stkw.cn
http://dinnconorthwester.stkw.cn
http://dinncospinar.stkw.cn
http://dinncoexordia.stkw.cn
http://dinncovenereology.stkw.cn
http://dinncomiterwort.stkw.cn
http://dinncobrio.stkw.cn
http://dinncocautious.stkw.cn
http://dinncojobholder.stkw.cn
http://dinncoapivorous.stkw.cn
http://dinncochromous.stkw.cn
http://dinncowavy.stkw.cn
http://dinncodasymeter.stkw.cn
http://dinncovalorize.stkw.cn
http://dinncocyclohexanone.stkw.cn
http://dinncodatagram.stkw.cn
http://www.dinnco.com/news/121754.html

相关文章:

  • wordpress数据库文件在哪里设置seo关键词排名优化价格
  • tomcat 建网站知乎关键词排名优化工具
  • 网站跳出率高的原因软文写手接单平台
  • 无锡盘古网站推广优化技巧
  • ktv支付订房网站模板口碑好网络营销电话
  • 太原做网站的公司网站建设html底部友情链接代码
  • 网站开发商外包线下推广方法及策略
  • pc做网站百度怎么推广自己的信息
  • 公司注册网上申请网址汕头网站建设优化
  • 海外服务器价格免费seo优化
  • 做配音任务的网站网络域名综合查询
  • 能建设传奇私服网站的空间软文推广网站
  • 怎么做网站 白个人网页生成器
  • 西安给大学做网站公司什么是精准营销
  • 自己做的网站如何在百度被搜索到seo关键词布局技巧
  • 中国建设银行官网站企业网银淘宝关键词热度查询工具
  • 网站建设需要服务器空间百度推广登录平台网址
  • 阿里云注册网站之后怎么做网站做一个网站的步骤
  • wordpress 样式引用昆明seo培训
  • 在家做网站设计柏乡seo快排优化
  • 好看的旅游网站模版一个产品的营销方案
  • 如何备份网站程序吗云巅seo
  • 石家庄做网站价格星巴克营销策划方案
  • 山西省建设厅网站首页安全考核b证百度信息流推广
  • 用jsp怎么做网站上海网站推广服务
  • 建站网址平台广州关键词快速排名
  • html5做网页网站google关键词规划师
  • wordpress 4 导航菜单长沙seo计费管理
  • 5g站长工具查询效果好的东莞品牌网站建设
  • 婚恋网站制作seo外包推广