开发者

Adding HTML5 placeholder attribute to spring 3.0 form input elements

开发者 https://www.devze.com 2023-01-26 05:52 出处:网络
How do I add HTML5 placeholder attributes to Spring webmvc\'s form:input, form:开发者_如何学编程password and form:textarea elements?As of Spring 3.0 form tags support dynamic attributes, therefore you

How do I add HTML5 placeholder attributes to Spring webmvc's form:input, form:开发者_如何学编程password and form:textarea elements?


As of Spring 3.0 form tags support dynamic attributes, therefore you can simply write

<form:input placeholder = "..." ... />


Regarding the new input types question - I had success by using spring bind and manually generating the input element. I'm using bootstrap so I already had a tag to wrap the control-group and apply the error message, but if you just want to inline it you can do the following.

if your path field was 'age', replace <form:input path="age"/> with

<spring:bind path="age">
  <input id="age" name="age" type="number" value="${status.value}" />
</spring:bind>
0

精彩评论

暂无评论...
验证码 换一张
取 消