spring boot 加入模板,並實現展現模板,實現新增數據

  1. 在pom.xml文件中加入

  2. <!-- thymeleaf 模板  -->
    	     <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-thymeleaf</artifactId>
            </dependency>

    在以下文件中加入以下代碼

    spring.mvc.view.prefix=/templates
    spring.mvc.view.suffix=.html

     

  3. 在 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 層加入

Dao 層不需要設置

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章