java Spring表单输入不能被禁用

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29391682/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 15:11:12  来源:igfitidea点击:

Spring form input can't be disable

javaspringformsinput

提问by Jerome Campeaux

I want to disable a <form:input>with the attribute disabled, but it's not working.

我想在禁用<form:input>属性的情况下禁用 a,但它不起作用。

<td class="value">
                <sec:authorize access="hasAnyRole('ROLE_EDIT_DEVICE_INSTALL_DATE')">
                    <form:input path="installDt"  maxlength="10" size="10"  cssClass="installDatePicker" /> 
                    <form:errors path="installDt" cssClass="errormsg" />
                </sec:authorize>
                <sec:authorize access="!hasAnyRole('ROLE_EDIT_DEVICE_INSTALL_DATE')">
                    <form:input path="installDt"  maxlength="10" size="10"  cssClass="installDatePicker" disabled="disabled" /> 
                    <form:errors path="installDt" cssClass="errormsg" />
                </sec:authorize>  
</td>

Does anybody have any idea to solve it ?

有没有人有任何想法来解决它?

采纳答案by Jerome Campeaux

I remove the cssClass date picker and set the disabled boolean to true and it works

我删除了 cssClass 日期选择器并将禁用的布尔值设置为 true 并且它可以工作

回答by minion

To disable it, use disabled=true. It accepts true|false.

要禁用它,请使用disabled=true. 它接受真|假。

<form:input path="installDt"  maxlength="10" size="10"  cssClass="installDatePicker" disabled="true" />

回答by Gorkem Sevim

When I try to do input disable with disabled="true", the data is null at core code, but when I try it with readonly, it did this properly.

当我尝试使用 禁用输入时disabled="true",核心代码中的数据为空,但是当我尝试使用 readonly 时,它正确地执行了此操作。

Try readonly="readonly"

尝试 readonly="readonly"

回答by susan097

When I place disabled="disable"it won't work

当我放置disabled="disable"它时它不起作用

When I place disabled="true"the value in the receiving end is null

当我把disabled="true"值放在接收端时为空

When I place readonly="true"It works for me.

当我放置readonly="true"它时它对我有用。