如何禁用 mvc html 字段?

How to make a mvc html field disabled?

我有一个 create.html 表单,其中包含从我的 spring roo 2.0 域模型生成的字段:

<div class="form-group has-error has-feedback" data-z="790e58b4" id="consultation-prediction-field" data-th-classappend="${#fields.hasErrors('prediction')}? 'has-error has-feedback'" data-th-class="form-group">
  <label for="prediction" class="col-md-3 control-label" data-th-text="#{label_consultation_prediction}">prediction</label>
  <div class="col-md-3">
    <input id="prediction" name="prediction" data-th-value="*{{prediction}}" type="text" class="form-control inputmask" placeholder="prediction" data-th-placeholder="#{label_consultation_prediction}" data-toggle="tooltip" aria-describedby="predictionStatus" data-inputmask-alias="numeric" data-inputmask-digits="2" />
      <span data-th-classappend="${#fields.hasErrors('prediction')}? 'glyphicon glyphicon-remove form-control-feedback'" class="glyphicon glyphicon-remove form-control-feedback" data-th-if="${#fields.hasErrors('prediction')}" aria-hidden="true"></span>
      <span id="prediction-error" class="help-block" data-th-if="${#fields.hasErrors('prediction')}" data-th-errors="*{prediction}">Error message.</span>
  </div>
</div>

我想禁用 UI 中的字段。我试图将 disabled 属性添加到 input 字段定义:

<div class="form-group has-error has-feedback" data-z="790e58b4" id="consultation-prediction-field" data-th-classappend="${#fields.hasErrors('prediction')}? 'has-error has-feedback'" data-th-class="form-group">
  <label for="prediction" class="col-md-3 control-label" data-th-text="#{label_consultation_prediction}">prediction</label>
  <div class="col-md-3">
    <input id="prediction" name="prediction" disabled data-th-value="*{{prediction}}" type="text" class="form-control inputmask" placeholder="prediction" data-th-placeholder="#{label_consultation_prediction}" data-toggle="tooltip" aria-describedby="predictionStatus" data-inputmask-alias="numeric" data-inputmask-digits="2" />
      <span data-th-classappend="${#fields.hasErrors('prediction')}? 'glyphicon glyphicon-remove form-control-feedback'" class="glyphicon glyphicon-remove form-control-feedback" data-th-if="${#fields.hasErrors('prediction')}" aria-hidden="true"></span>
      <span id="prediction-error" class="help-block" data-th-if="${#fields.hasErrors('prediction')}" data-th-errors="*{prediction}">Error message.</span>
  </div>
</div>

这暂时有效,但 spring roo 在重新生成表单时删除了这个 disabled 属性。

如何永久设置此属性?

看来我只需要设置属性:

data-z="user-managed" 

form-group字段中。