2017-03-15 22 views
0

データベースに段落を含むテキストがありますが、このテキストはjavaでSystem.out.println();と表示されますが、このテキストをUIに表示すると、すべてのテキストが1行に表示されます。 Data BaseDB(Spring)からUI上の段落でテキストを表示する方法は?

春:

ModelAndView modelAndView = new ModelAndView(); 
    modelAndView.addObject("allText",dtos); 
    modelAndView.setViewName("test"); 
    return modelAndView; 

だから私は、UIに表示してみてください:

<div th:each="text: ${allText}"> 
     <div align="center" > 
      <b><span th:text="${text.description}">description</span></b> 
     </div> 
</div> 

私のミス?

+0

可能な複製(http://stackoverflow.com/questions/30394419/thymeleaf-spring-how-to-keep-line-break) – Metroids

+0

感謝君は!すべては今働いている。 – Viking

答えて

0
th:utext="${#strings.unescapeJava(#strings.replace(#strings.escapeJava(text.description),'\n','&lt;br /&gt;'))}" 
[Thymeleaf +春?:改行を保つ方法]の
+1

このコードスニペットは問題を解決するかもしれませんが、[説明を含む](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)は本当にあなたの投稿の質を向上させるのに役立ちます。将来読者の質問に答えていることを覚えておいてください。そうした人々はあなたのコード提案の理由を知らないかもしれません。 – DimaSan

+0

私の質問で答えを見つけることができません、メトロイドはいくつかの同様のリンクを与え、私は問題の解決を示します – Viking

+0

@Vikingこのリンクをチェックしましたか? http://stackoverflow.com/questions/23156585/process-thymeleaf-variable-as-html-code-and-not-string – cralfaro

関連する問題