setting class and other attributes for spring form tag element

html, java, jsp, spring-mvc

Solution

Ok I resolved some part of it. Looks like tags used inside form:input tag are different than regular html tags. All of them are listed here. For ex `style` is `cssStyle`.

So I change my code to

`<form:input path="username" cssClass="text simpleTextField" maxlength="200" cssStyle="width:60%" disabled="true"/>`

and now it works..

I still don't know how to populate value in this input. These seems no equivalent of `value` keyword.

Problem

I have the following page and it does not load ``` <form:form action="/test.htm" method="post" commandName="demoForm" > <div id="testSection" style="margin-top: 1.5%;margin-left: 3.5%;"> <span class="test-container"> <label>UserName</label> <span class="test-container-right"> <form:input path="username" value="${UNAME}" class="text simpleTextField" maxlength="200" style="width:60%" disabled/> </span> </span> <span style="width:auto; padding-left: 30%; padding-bottom: 4%; text-align:center; float:right; clear:both;"> <input type="submit" class="btn" style="width:auto;" value="Save" /> </span> </div> </form:form> ``` but when I change it to ``` ... <span class="test-container-right"> <form:input path="username" /> </span> ... ``` it works and loads correctly. Why am I not allowed to set html properties for form:input spring tag. How can I achieve this? On inspecting the element it expands to be ``` <input id="username" type="text" value="" name="username"></input> ``` I need to populate its value as well as provide it with a class and additional attributes like width.

Original source