zoukankan      html  css  js  c++  java
  • Sping 补充完成修改功能

    1.视图层完整示例

    	<form action="#" th:action="@{/update/{id}(id=${user.id})}" th:object="${user}" method="post" >
    		<label for="name" >姓名</label>
    		<input type="text" th:field="*{name}" id="name" placeholder="Name" >
    		
    		<p th:if="${#fields.hasErrors('name')}" th:errors="*{name}" ></p>
    		
    		<label for="age">年龄</label>
    		<input type="text" th:field="*{age}"   id="age" placeholder="age" name="age">
    		
    		<p th:if="${#fields.hasErrors('age')}" th:errors="*{age}"></p>
    		
    		<label for="email">邮箱</label>
    		<input type="text" th:field="*{email}" id="email" placeholder="Email">
    		
    		<p th:if="${#fields.hasErrors('email')}" th:errors="*{email}" ></p>
    		
    		<input type="submit" value="修改">
    	</form>
    

      2.控制器层代码

    	@PostMapping("/edit/{id}")
    	public String editUser(@Valid User user,BindingResult bindingResult) {
    		
    		if(bindingResult.hasErrors()) {
    			return "update-user";
    		}
    		return "update-user";
    	}

    动图示例

  • 相关阅读:
    s2-032批量脚本
    javascript 1
    threading模块和queue模块实现程序并发功能和消息队列
    Python标准库06 子进程 (subprocess包)
    常用服务对应的正则
    re
    requests
    198. 打家劫舍
    746. 使用最小花费爬楼梯
    70. 爬楼梯
  • 原文地址:https://www.cnblogs.com/max-hou/p/11107095.html
Copyright © 2011-2022 走看看