httpclient 如何设置多个checkbox

本文探讨了在一个页面上存在两个具有相同名称的复选框时,在使用httpclient的postmethod进行表单提交过程中遇到的问题。作者尝试设置这两个复选框的值但未成功,寻求解决方案。

 一个问题不知如何解决,google和baidu都无结果,谁能解决?

 

<input style="cursor: pointer;" type="checkbox" id="journals" name="source" value="srcJrl" CHECKED>Journals</label>
<input style="cursor: pointer;" type="checkbox" id="books" name="source" value="srcBk" CHECKED>All Books</label>
页面上两个checkbox都是被选中的,而这连个checkbox的name 相同。
在httpclient 中使用postmethod提交表单时
设定表单参数时,写法如下:
post.setParameter("source", "srcJrl");
但是这样只设置了一个,怎样两个都设置呢?
总不能再写类似一句吧
post.setParameter("source", "srcbk");
这样试过了,只有后面这句起作用的。
那到底怎么设呢?
要是有高人能指点迷津,请不吝赐教。
它是一个图片的地址,如何让渲染成功?源代码 List<ProductionSpecification> specList = productionSpecificationDataService.selectProductionSpecificationDataList(productionSpecificationData); specList.forEach(spec->{ // 构建模板数据 Map<String, Object> data = new HashMap<>(); // 客户与项目信息 data.put("customerName", spec.getCustomerName()); data.put("projectName", spec.getProjectName()); data.put("batteryFinishedProductMaterialNumber", spec.getBatteryFinishedProductMaterialNumber()); data.put("pcbSemiFinishedProductMaterialNumber", spec.getPcbSemiFinishedProductMaterialNumber()); // 电芯信息 data.put("batteryCellBrand", spec.getBatteryCellBrand()); data.put("batteryCellModel", spec.getBatteryCellModel()); data.put("maxBatteryCellInternalResistance", spec.getMaxBatteryCellInternalResistance()); data.put("batteryCellGroupMaxInternalResistanceDifference", spec.getBatteryCellGroupMaxInternalResistanceDifference()); data.put("batteryCellGroupMaxVoltageDifference", spec.getBatteryCellGroupMaxVoltageDifference()); data.put("batteryCellGroupMaxCapacityDifference", spec.getBatteryCellGroupMaxCapacityDifference()); data.put("batteryCellPowerOnSequencePcb", spec.getBatteryCellPowerOnSequencePcb()); // PCB信息 data.put("pcbSilkScreen", spec.getPcbSilkScreen()); data.put("pcbMaterialNumber", spec.getPcbMaterialNumber()); // 充电保护设置 data.put("level1ChargeOvervoltageProtection", spec.getLevel1ChargeOvervoltageProtection()); data.put("level1ChargeOvervoltageProtectionDelay", spec.getLevel1ChargeOvervoltageProtectionDelay()); data.put("level1ChargeOvervoltageProtectionRelease", spec.getLevel1ChargeOvervoltageProtectionRelease()); data.put("level2ChargeOvervoltageProtection", spec.getLevel2ChargeOvervoltageProtection()); data.put("level2ChargeOvervoltageProtectionDelay", spec.getLevel2ChargeOvervoltageProtectionDelay()); // 放电保护设置 data.put("dischargeUndervoltageProtection", spec.getDischargeUndervoltageProtection()); data.put("dischargeUndervoltageProtectionDelay", spec.getDischargeUndervoltageProtectionDelay()); data.put("dischargeUndervoltageProtectionRelease", spec.getDischargeUndervoltageProtectionRelease()); // 过流保护设置 data.put("chargeOvercurrentProtection", spec.getChargeOvercurrentProtection()); data.put("chargeOvercurrentProtectionDelay", spec.getChargeOvercurrentProtectionDelay()); data.put("chargeOvercurrentRelease", spec.getChargeOvercurrentRelease()); data.put("level1DischargeOvercurrentProtection", spec.getLevel1DischargeOvercurrentProtection()); data.put("level1DischargeOvercurrentProtectionDelay", spec.getLevel1DischargeOvercurrentProtectionDelay()); data.put("level2DischargeOvercurrentProtection", spec.getLevel2DischargeOvercurrentProtection()); data.put("level2DischargeOvercurrentProtectionDelay", spec.getLevel2DischargeOvercurrentProtectionDelay()); // 短路保护 data.put("shortCircuitProtection", spec.getShortCircuitProtection()); data.put("shortCircuitProtectionDelay", spec.getShortCircuitProtectionDelay()); data.put("dischargeOvercurrentRelease", spec.getDischargeOvercurrentRelease()); // 阻抗与功耗 data.put("packInternalResistance", spec.getPackInternalResistance()); data.put("jpPointConnectivityTest", spec.getJpPointConnectivityTest()); data.put("ntc1ResistanceTest", spec.getNtc1ResistanceTest()); data.put("ntc2ResistanceTest", spec.getNtc2ResistanceTest()); data.put("bMinusToPMinusResistance", spec.getbMinusToPMinusResistance()); data.put("bPlusToPPositiveResistance", spec.getbPlusToPPositiveResistance()); data.put("operatingPowerConsumption", spec.getOperatingPowerConsumption()); data.put("sleepPowerConsumption", spec.getSleepPowerConsumption()); // 充放电状态 data.put("normalCharging", spec.getNormalCharging()); data.put("normalDischarging", spec.getNormalDischarging()); data.put("openCircuitVoltage", spec.getOpenCircuitVoltage()); // 充电模式 data.put("ccCvCharging", spec.getCcCvCharging()); // 活化流程 data.put("fullActivationStand", spec.getFullActivationStand()); data.put("constantCurrentDischarge", spec.getConstantCurrentDischarge()); data.put("fullActivationChargeToShipmentVoltage", spec.getFullActivationChargeToShipmentVoltage()); data.put("simpleActivationChargeToShipmentVoltage", spec.getSimpleActivationChargeToShipmentVoltage()); data.put("simpleActivationStand", spec.getSimpleActivationStand()); // 放电容量 data.put("dischargeCapacity", spec.getDischargeCapacity()); // 图纸链接 data.put("pcbSchematicDiagramTop", spec.getPcbSchematicDiagramTop()); data.put("pcbSchematicDiagramBottom", spec.getPcbSchematicDiagramBottom()); data.put("pcmPortDiagram", spec.getPcmPortDiagram()); data.put("batteryOutputPortDiagram", spec.getBatteryOutputPortDiagram()); data.put("ntcResistanceRTTable1", spec.getNtcResistanceRTTable1()); data.put("ntcResistanceRTTable2", spec.getNtcResistanceRTTable2()); // 测试方法勾选框 data.put("checkbox1", spec.getCheckbox1()); data.put("checkbox2", spec.getCheckbox2()); data.put("checkbox3", spec.getCheckbox3()); data.put("checkbox4", spec.getCheckbox4()); data.put("checkbox5", spec.getCheckbox5()); data.put("checkbox6", spec.getCheckbox6()); data.put("checkbox7", spec.getCheckbox7()); data.put("checkbox8", spec.getCheckbox8()); data.put("checkbox9", spec.getCheckbox9()); data.put("checkbox10", spec.getCheckbox10()); data.put("checkbox11", spec.getCheckbox11()); data.put("checkbox12", spec.getCheckbox12()); data.put("checkbox13", spec.getCheckbox13()); data.put("checkbox14", spec.getCheckbox14()); data.put("checkbox15", spec.getCheckbox15()); data.put("checkbox16", spec.getCheckbox16()); data.put("checkbox17", spec.getCheckbox17()); data.put("checkbox18", spec.getCheckbox18()); data.put("checkbox19", spec.getCheckbox19()); data.put("checkbox20", spec.getCheckbox20()); data.put("checkbox21", spec.getCheckbox21()); data.put("checkbox22", spec.getCheckbox22()); data.put("checkbox23", spec.getCheckbox23()); data.put("checkbox24", spec.getCheckbox24()); data.put("checkbox25", spec.getCheckbox25()); data.put("checkbox26", spec.getCheckbox26()); data.put("checkbox27", spec.getCheckbox27()); data.put("checkbox28", spec.getCheckbox28()); data.put("checkbox29", spec.getCheckbox29()); // 版本记录(拼接为字符串) if (spec.getVersionRecordList() != null && !spec.getVersionRecordList().isEmpty()) { StringBuilder versionRecords = new StringBuilder(); for (ProductionSpecificationVersionRecord record : spec.getVersionRecordList()) { versionRecords.append("版本: ").append(record.getRevision()) .append(", 更新人: ").append(record.getUpdateBy()) .append(", 时间: ").append(record.getUpdateTime()) .append("\n"); } data.put("versionRecords", versionRecords.toString()); } // 加载模板 ClassPathResource resource = new ClassPathResource("templates/production_specification_temlate.docx"); try (InputStream in = resource.getInputStream()) { XWPFTemplate template = XWPFTemplate.compile(in).render(data); // 设置响应头 response.setContentType("application/vnd.openxmlformats-officedocument.wordprocessingml.document"); response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=production_specification.docx"); // 输出文件 template.write(response.getOutputStream()); } catch (IOException e) { // 处理异常,可以抛出运行时异常或返回错误响应 throw new RuntimeException("读取模板文件失败", e); } });
最新发布
11-28
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值