-
在pom.xml文件中加入
-
<!-- thymeleaf 模板 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
在以下文件中加入以下代碼
spring.mvc.view.prefix=/templates spring.mvc.view.suffix=.html
-
在 template目錄下 加入
add.html中爲
<form method="get" action="/stu/save" >
班組編碼<input type="text" name="code" />
班組名稱<input type="text" id="unitName" name="name" />
<input name="submit" type="submit" value="提交">
</form>
在控制器中加入
訪問效果:
提交到 save 方法
只需要在 service 層加入