我想将Spring Boot MVC与FreeMarker一起使用,并以与JSP标签的方式相似的方式显示表单。例如。此表格:
<form:form method="post" action="save" modelAttribute="form" class="form-horizontal">
<form:hidden path="id"/>
<div class="form-group">
<label for="name" class="col-sm-2 control-label">Name</label>
<div class="col-sm-10">
<form:input id="name" path="name" class="form-control" />
</div>
</div>
</form:form>
自然,标签表单:表单,表单:输入,表格:隐藏等。不支持。有没有办法将模型绑定到freemarker中的视图?
这里是:
http://docs.spring.io/spring/docs/current/spring-framework-reference/html/html/view.html#view-view-simple-binding
<!-- freemarker macros have to be imported into a namespace. We strongly
recommend sticking to spring -->
<#import "/spring.ftl" as spring />
<html>
...
<form action="" method="POST">
Name:
<@spring.bind "command.name" />
<input type="text"
name="${spring.status.expression}"
value="${spring.status.value?default("")}" /><br>
<#list spring.status.errorMessages as error> <b>${error}</b> <br> </#list>
<br>
...
<input type="submit" value="submit"/>
</form>
...
</html>