(テンプレートエンジンthymleaf)春ブーツの研究ノート

導入、のpom.xml

<依存性> 
<のgroupId> org.springframework.boot </のgroupId>
<たartifactId>ばねブートスタータthymeleaf </たartifactId>
</依存>

二、増加関連の設定をapplication.properties

#近いキャッシュされた開発、またはライブページを見ることができない
spring.thymeleaf.cache = falseを
spring.thymeleaf.mode HTML5 =
#プレフィックス
spring.thymeleaf.prefix = CLASSPATH:/テンプレート/
#コーディング
spring.thymeleaf.encoding = UTF-を8
#型
spring.thymeleaf.content型=テキスト/ HTMLの
#名サフィックス
spring.thymeleaf.suffix = .htmlを

 

三、テンプレートは、新しいHTMLページを作成するフォルダ

<!DOCTYPE HTML > 
< HTML LANG = "EN" > 
< > 
    < メタ文字コード= "UTF-8" > 
    < タイトル>インデックス</ タイトル> 
</ ヘッド> 
< 身体> 
これは、インデックスポータルサイトです!
</ ボディ> 
</ HTML >

 

第四に、新しいクラスを作成し、トップに新しいHTMLページジャンプ

以下のためのパッケージ変更。net.Eleven.demo.controller 

インポートorg.springframework.stereotype.Controller;
 インポートorg.springframework.web.bind.annotation.RequestMapping; 


@Controllerが// 使用RestControllerはコメントできない注意 
RequestMapping @( "/ Thymeleaf" 公衆 クラスThymeleafController { 
    @RequestMapping(「こんにちは」パブリックオブジェクトハロー(){
         リターン「インデックス」;     // ないサフィックス、増加するコンフィギュレーション・ファイルに配置されています
    } 
}

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

おすすめ

転載: www.cnblogs.com/Eleven-Liu/p/11031903.html