Java(Springboot)

get请求

在Controller中--->从仓库里取出要用的mysql----->对于get请求(httpsession,model容器)----->从httpsession取出userid再赋值给userid----->用userid在mysql获取用户的信息------>然后用户的信息在保存在model容器里---->return到html地址里面

put请求

得到请求体的参数--->从httpsession取出userid再赋值给userid----->根据用户id查找数据库----->更新user_id里面的数据------>保存到数据库里面-----return ResponseEntity.ok

Thymeleaf 语法解释

复制代码
​
<span th:text="${user.username}"></span>
<a th:href="@{/profile/{id}(id=${user.id})}">View Profile</a>
<img th:src="@{${user.profilePictureUrl}}" alt="User Profile Picture"/>
<img th:src="@{${user.profilePictureUrl}}" alt="User Profile Picture"/>
<div th:class="${user.active} ? 'active' : 'inactive'">User Profile</div>
<p th:if="${user.isActive}">User is active</p>
<p th:unless="${user.isActive}">User is inactive</p>
<ul>
    <li th:each="user : ${users}" th:text="${user.username}"></li>
</ul>
<form th:action="@{/submit}" th:object="${user}">
    <input type="text" th:field="*{username}" />
    <input type="password" th:field="*{password}" />
    <button type="submit">Submit</button>
</form>

​

123

相关推荐
Grey Zeng16 分钟前
Java SE 25新增特性
java·jdk·jdk新特性·jdk25
雨白2 小时前
Java 线程通信基础:interrupt、wait 和 notifyAll 详解
android·java
昵称为空C5 小时前
SpringBoot3 http接口调用新方式RestClient + @HttpExchange像使用Feign一样调用
spring boot·后端
架构师沉默6 小时前
设计多租户 SaaS 系统,如何做到数据隔离 & 资源配额?
java·后端·架构
Java中文社群7 小时前
重要:Java25正式发布(长期支持版)!
java·后端·面试
每天进步一点_JL8 小时前
JVM 类加载:双亲委派机制
java·后端
用户298698530149 小时前
Java HTML 转 Word 完整指南
java·后端
渣哥9 小时前
原来公平锁和非公平锁差别这么大
java
渣哥9 小时前
99% 的人没搞懂:Semaphore 到底是干啥的?
java
J2K9 小时前
JDK都25了,你还没用过ZGC?那真得补补课了
java·jvm·后端