<form:label path="company">Enter company name:</form:label>
渲染 -
<label for="company">Enter company name:</label>
为什么不直接使用更简洁的HTML标签呢?
最佳答案
<form:label />
标签可以访问底层模型和绑定(bind)结果,因此在出错时可以使用另一个样式类。
<form:label cssClass="title" cssErrorClass="title error" path="company" />
如果出现错误,上面的代码将呈现与正常情况不同的效果。当然,您也可以在没有表单标签的情况下执行此操作,但这意味着您需要在页面中包含一些逻辑,通常不建议这样做。
有关所有属性,请参阅 reference guide
关于java - :label tag in Spring?形式有什么好处,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21593988/