【发布时间】:2014-03-22 03:24:02
【问题描述】:
在 Web 应用程序中,我们不想使用 JSP 文件,我们只想使用 HTML 文件。每个视图都是一个模板。
我正在寻找一种方法来设置 spring,spring security 以直接使用 login.html 文件,如果用户验证正确,则通用布局(顶层、左层、右层和中心层和南层)将是显示出来。
【问题讨论】:
标签: html spring spring-mvc spring-security
在 Web 应用程序中,我们不想使用 JSP 文件,我们只想使用 HTML 文件。每个视图都是一个模板。
我正在寻找一种方法来设置 spring,spring security 以直接使用 login.html 文件,如果用户验证正确,则通用布局(顶层、左层、右层和中心层和南层)将是显示出来。
【问题讨论】:
标签: html spring spring-mvc spring-security
您正在寻找的是natural templating 解决方案,其中模板直接在 HTML 和 CSS 中构建,标签中只有一些特殊属性,但不需要一组 XML 标签库。
Thymeleaf 模板技术是一种解决方案 - Comparison of a Thymeleaf template with a JSP in a Spring application
这是一个模板的样子:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Spring MVC view layer: Thymeleaf vs. JSP</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="all"
href="../../css/thvsjsp.css" th:href="@{/css/thvsjsp.css}"/>
</head>
<body>
<h2>This is a Thymeleaf template</h2>
<form action="#" th:object="${subscription}" th:action="@{/subscribeth}">
<fieldset>
<div>
<label for="email" th:text="#{subscription.email}">Email: </label>
<input type="text" th:field="*{email}" />
</div>
<div>
<label th:text="#{subscription.type}">Type: </label>
<ul>
<li th:each="type : ${allTypes}">
<input type="radio" th:field="*{subscriptionType}" th:value="${type}" />
<label th:for="${#ids.prev('subscriptionType')}"
th:text="#{'subscriptionType.'+${type}}">First type</label>
</li>
<li th:remove="all"><input type="radio" /> <label>Second Type</label></li>
</ul>
</div>
<div class="submit">
<button type="submit" name="save" th:text="#{subscription.submit}">Subscribe me!</button>
</div>
</fieldset>
</form>
</body>
</html>
【讨论】: