html-disabled="disabled"关于属性后台取值问题

博客指出在HTML中设置控件disabled属性为只读时,SpringMVC无法获取数据。因此,需在表单提交前移除disabled属性,并给出了相关表单代码和移除属性的函数示例,以确保能正常获取数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

disabled="disabled"位设置当前控件为只读,这个时候咱们在通过后台来获取数据的时候,springmvc就不能够获取到值,
所以我问需要在表单提交前,移除disabled属性

<form:select path="payStatus" class="form-control " disabled="true">
         <form:options items="${fns:getDictList('pay_status')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
</form:select>

function doSubmit(){//回调函数,在编辑和保存动作时,供openDialog调用提交表单。
          if(validateForm.form()){
              
              $("#payStatus").removeAttr("disabled");
              
              $("#inputForm").submit();
              return true;
          }
    
          return false;
}

 

disabled属性$("#role").removeAttr("disabled");

<template> <div> <el-dialog title="设备导入" :visible.sync="dialogVisible" width="600px" custom-class="ota-dialog" :close-on-click-modal="false" > <div class="dialog-content"> <!-- 操作区域 --> <div class="action-section"> <div class="upload-section"> <el-upload @click="handleUploadSuccess()" :before-upload="beforeUpload" :limit="1" :on-exceed="handleExceed" :file-list="fileList" :class="{ 'has-file': fileList.length }" drag > <i class="el-icon-upload"></i> <div class="el-upload__text"> <div>点击或拖拽文件到此处上传</div> <div class="el-upload__tip">支持.xlsx、.xls格式文件</div> </div> </el-upload> <!-- 文件信息卡片 --> <div v-if="fileList.length" class="file-card"> <div class="file-info"> <i class="el-icon-document"></i> <div class="file-details"> <div class="file-name">{{ fileList[0].name }}</div> <div class="file-size">{{ formatFileSize(fileList[0].size) }}</div> </div> </div> <el-button type="danger" icon="el-icon-delete" circle @click="fileList = []" ></el-button> </div> </div> </div> </div> <!-- 底部按钮 --> <div slot="footer" class="dialog-footer"> <el-button @click="dialogVisible = false">取 消</el-button> <el-button type="primary" @click="otaBatchUpgradeConfirm()" :disabled="!fileList.length" > 确定 </el-button> </div> </el-dialog> </div> </template> <script> export default { data() { return { dialogVisible: false, fileList: [] }; }, methods: { init() { this.dialogVisible = true; this.fileList = []; }, otaBatchUpgradeCinfirm() { // 升级逻辑 }, handleUploadSuccess(response, file, fileList) { this.$message.success('文件上传成功'); this.fileList = fileList; }, beforeUpload(file) { const isValidType = [ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-excel' ].includes(file.type); if (!isValidType) { this.$message.error('请上传Excel格式的文件 (.xlsx 或 .xls)'); } return isValidType; }, handleExceed() { this.$message.warning('每次只能上传一个文件'); }, formatFileSize(size) { if (size < 1024) return size + ' B'; if (size < 1024 * 1024) return (size / 1024).toFixed(1) + ' KB'; return (size / (1024 * 1024)).toFixed(1) + ' MB'; } } }; </script> <style scoped> /* 操作区域 */ .action-section { display: flex; flex-direction: column; gap: 20px; } .upload-section { position: relative; display: flex; justify-content: center; } /* 文件卡片 */ .file-card { margin-top: 15px; padding: 15px; border-radius: 8px; background-color: #f5f7fa; display: flex; align-items: center; justify-content: space-between; border: 1px solid #ebeef5; } .file-info { display: flex; align-items: center; gap: 12px; } .file-info i { font-size: 28px; color: #409EFF; } .file-details { line-height: 1.5; } .file-name { font-weight: 500; max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .file-size { font-size: 12px; color: #909399; } /* 底部按钮 */ .dialog-footer { display: flex; justify-content: flex-end; padding-top: 15px; border-top: 1px solid #ebeef5; } /* 上传区域激活状态 */ .has-file >>> .el-upload-dragger { border: 1px dashed #67C23A; background-color: rgba(103, 194, 58, 0.05); } </style> 读取excel 第一行第一列的数据并用 分号;隔开拼成一个字符串
最新发布
07-12
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

javachen__

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值