似非プログラマのうんちく

「似非プログラマの覚え書き」出張版

Thymeleaf

春だから Spring やろうぜ(その 10)

入力用のフォームを準備して、データを入力・保存できるようにする。 <html xmlns:th="http://www.thymeleaf.org"> <head> <title>Top page</title> <link th:href="@{/css/hello.css}" rel="stylesheet" /> </head> <body> <h1 th:text="#{content.title}">Top page</h1> <form method="post" action="/" th:object="${formModel}"> </form></body></html>

春だから Spring やろうぜ(その 8)

Thymeleaf で使えるメッセージ式 /src/main/resources フォルダに messages.properties ファイルを作り、以下の内容で保存する。 content.title=Sample page content.message=This is sample message from properties. こうするとテンプレート内で #{content…

春だから Spring やろうぜ(その 2)

テンプレートを使ってみる 出力する文字列に HTML を直接打てば表示はされるけど当然ながら面倒くさい。そこで Thymeleaf というテンプレートを使うことにする。先ほどの app.groovy と同じフォルダに新たに templates というフォルダを作り、その中に index…