2017-06-08 8 views
1

私はthymeleafスニペットを次ています変数がページ上でレンダリングされないのはなぜですか?

... 
    <p>///////</p> 
    ${userName} 
    <p>///////</p> 
    ... 

を私はfollowinfコントローラがあります。

GetMapping(value = {"/main"}) 
    public String showPersonsPage(Model model) { 
     // don't fill models here. All data got via web socket's subscription. 
     model.addAttribute("userName", startupHouseKeeper.getUser().getUserName()); 
     return "main"; 
    } 

しかし、ページ上に私が参照してください。
私が間違っていた何 enter image description here

${userName}使用の

答えて

3

Inteads:彼らはHTMLタグの外にある場合

[[${userName}]] 

は常に角括弧で変数を囲みます。追加の括弧なしのソリューション下:あなたの変数を使用して

<p th:text="${userName}"></p> 
1

出力:

<p th:text="${userName}"></p> 
関連する問題