刚开始用spring表单,想把文本框设置为只读,用readonly="readonly" 设置了半天,还是可以编辑该文本框。
在网上搜索了很久都没有解决方法,最后到spring的网站,看了他们的说明文档才知道,spring表单的input是不支持readonly="readonly"的。
只支持readonly="true" 或者readonly="false" ,这样才可以设置文本框的只读属性。
以下是input标签的一些说明:
E.7. The input tag
Renders an HTML 'input' tag with type 'text' using the bound value.
Table E.6. Attributes
Attribute | Required? | Runtime Expression? | Description |
---|---|---|---|
accesskey | false | true | HTML Standard Attribute |
alt | false | true | HTML Optional Attribute |
autocomplete | false | true | Common Optional Attribute |
cssClass | false | true | Equivalent to "class" - HTML Optional Attribute |
cssErrorClass | false | true | Equivalent to "class" - HTML Optional Attribute. Used when the bound field has errors. |
cssStyle | false | true | Equivalent to "style" - HTML Optional Attribute |
dir | false | true | HTML Standard Attribute |
disabled | false | true | HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will disable the HTML element. |
htmlEscape | false | true | Enable/disable HTML escaping of rendered values. |
id | false | true | HTML Standard Attribute |
lang | false | true | HTML Standard Attribute |
maxlength | false | true | HTML Optional Attribute |
onblur | false | true | HTML Event Attribute |
onchange | false | true | HTML Event Attribute |
onclick | false | true | HTML Event Attribute |
ondblclick | false | true | HTML Event Attribute |
onfocus | false | true | HTML Event Attribute |
onkeydown | false | true | HTML Event Attribute |
onkeypress | false | true | HTML Event Attribute |
onkeyup | false | true | HTML Event Attribute |
onmousedown | false | true | HTML Event Attribute |
onmousemove | false | true | HTML Event Attribute |
onmouseout | false | true | HTML Event Attribute |
onmouseover | false | true | HTML Event Attribute |
onmouseup | false | true | HTML Event Attribute |
onselect | false | true | HTML Event Attribute |
path | true | true | Path to property for data binding |
readonly | false | true | HTML Optional Attribute. Setting the value of this attribute to 'true' (without the quotes) will make the HTML element readonly. |
size | false | true | HTML Optional Attribute |
tabindex | false | true | HTML Standard Attribute |
title | false | true | HTML Standard Attribute |