<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Guestbook</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" />
</head>
    <body>

        <img th:src="@{/images/spring-logo.png}" />

        <h1>Guestbook</h1>

        <p>Current entries in the guestbook:</p>

        <table>
            <tr>
                <th>User</th><th>Comment</th><th></th>
            </tr>
            <tr th:each="entry: ${entries}">
                <td th:text="${entry.user}"></td>
                <td th:text="${entry.comment}"></td>
                <td><a th:href="@{'/delete/' + ${entry.id}}">Delete</a></td>
            </tr>
        </table>

        <h1>New Comment</h1>
        <form action="#" th:action="@{/}" th:object="${newEntry}" method="post">
            <p>User: <input type="text" th:field="*{user}" />
               Comment: <input type="text" th:field="*{comment}" /></p>

            <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
        </form>

    </body>
</html>
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Guestbook</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" />
</head>
    <body>

        <img th:src="@{/images/spring-logo.png}" />

        <h1>Guestbook</h1>

        <div th:if="${entries.isEmpty()}">
            <p>There are no comments in the Guestbook. What a pity.</p>
        </div>

        <div th:if="${!entries.isEmpty()}">
            <p>Current comments in the Guestbook:</p>

            <table>
                <tr>
                    <th>User</th><th>Comment</th><th></th>
                </tr>
                <tr th:each="entry: ${entries}">
                    <td th:text="${entry.user}"></td>
                    <td th:text="${entry.comment}"></td>
                    <td><a th:href="@{'/delete/' + ${entry.id}}">Delete</a></td>
                </tr>
            </table>
        </div>

        <h1>New Comment</h1>
        <form action="#" th:action="@{/}" th:object="${newEntry}" method="post">
            <p>User: <input type="text" th:field="*{user}" />
               Comment: <input type="text" th:field="*{comment}" /></p>

            <p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
        </form>

    </body>
</html>
Tweak form to handle empty guestbook by not display blank table.
Tweak form to handle empty guestbook by not display blank table.
