View Templates

Bei Spring-Basierten Webapplikationen werden in der Regel für die View Templates verwendet. Diese Views werden dann auf de, Server gerendert und an den Client geschickt.

Libraries

Es gibt mehrere View Template Libraries, welche alle kompatiblel sind mit Spring:

  • JSP/JSTL
  • Thymeleaf
  • Tiles
  • Freemarker
  • Velocity

Thymeleaf

SO könnte ein Template mit Thymeleaf aussehen:1

<form action="#" th:object="${searchCriteria}" th:action="@{/hotels}" method="get" class="inline">
    <ul th:if="${#fields.hasErrors('*')}" class="errors span-18">
        <li th:each="err : ${#fields.errors('*')}" th:text="${err}">Input is incorrect</li>
    </ul>
    <fieldset>
        <div class="span-8">
            <label for="searchString">Search String:</label>
            <input type="text" id="searchString" th:field="*{searchString}" />
        </div>
        ...
    </fieldset>
</form>

Since the version 3.x Springframework allows to write applications without any use of xml. It’s quite funny the idea that Spring the ‘xml oriented framework’ now is completely xml-free. 1

Quellen

1 http://javaee.ch/2013/11/02/basic-spring-mvc-annotation-based-configuration-example-with-thymeleaf-and-no-xml/

results matching ""

    No results matching ""