du781166309 2021-04-29 15:15 采纳率: 66.7%
浏览 155

get请求302找不到原因

  @RequestMapping(value = "/order/download", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void offlineApplicationTemplateExcelDownload(HttpServletResponse response) {
        OutputStream outputStream = null;
        try {
            response.reset();
            response.setCharacterEncoding("UTF-8");
            response.setHeader("Content-Disposition",
                    "attachment;filename=" + URLEncoder.encode("统采导入线下申请模板", "UTF-8") + ".xlsx");
            response.setContentType("application/msexcel;charset=UTF-8");
            outputStream = response.getOutputStream();
            Workbook workbook = new XSSFWorkbook();// 声明一个工作薄
            Sheet sheet = workbook.createSheet("线下申请模板");// 生成一个表格
            sheet.createFreezePane(0, 1);// 固定第一行
            sheet.setDefaultColumnWidth((short) 22);// 设置表格默认列宽度为15个字节
            sheet.setDefaultRowHeight((short) 800);

            CellStyle outerCellStype = workbook.createCellStyle(); // style
            outerCellStype.setBorderBottom(BorderStyle.MEDIUM);
            outerCellStype.setBottomBorderColor(IndexedColors.BLACK.getIndex());
            outerCellStype.setBorderLeft(BorderStyle.MEDIUM);
            outerCellStype.setLeftBorderColor(IndexedColors.BLACK.getIndex());
            outerCellStype.setBorderRight(BorderStyle.MEDIUM);
            outerCellStype.setRightBorderColor(IndexedColors.BLACK.getIndex());
            outerCellStype.setBorderTop(BorderStyle.MEDIUM);
            outerCellStype.setTopBorderColor(IndexedColors.BLACK.getIndex());
            Row comboTitleRow = sheet.createRow(0);// 套餐标题
            comboTitleRow.setHeight((short) 800);
            Cell t0 = comboTitleRow.createCell(0);
            t0.setCellValue("线下申请ID");
            t0.setCellStyle(outerCellStype);
            Cell t1 = comboTitleRow.createCell(1);
            t1.setCellValue("商品名称(最多90个字)*");
            t1.setCellStyle(outerCellStype);
            Cell t2 = comboTitleRow.createCell(2);
            t2.setCellValue("单价*");
            t2.setCellStyle(outerCellStype);
            Cell t3 = comboTitleRow.createCell(3);
            t3.setCellValue("数量*");
            t3.setCellStyle(outerCellStype);
            Cell t4 = comboTitleRow.createCell(4);
            t4.setCellValue("总价*");
            t4.setCellStyle(outerCellStype);
            Cell t5 = comboTitleRow.createCell(5);
            t5.setCellValue("供应商*");
            t5.setCellStyle(outerCellStype);
            Cell t6 = comboTitleRow.createCell(6);
            t6.setCellValue("供应商联系方式");
            t6.setCellStyle(outerCellStype);
            Cell t7 = comboTitleRow.createCell(7);
            t7.setCellValue("货号");
            t7.setCellStyle(outerCellStype);
            Cell t8 = comboTitleRow.createCell(8);
            t8.setCellValue("品牌");
            t8.setCellStyle(outerCellStype);
            Cell t9 = comboTitleRow.createCell(9);
            t9.setCellValue("规格");
            t9.setCellStyle(outerCellStype);
            Cell t10 = comboTitleRow.createCell(10);
            t10.setCellValue("备注");
            t10.setCellStyle(outerCellStype);
            // 示例数据
            CellStyle CellStype = workbook.createCellStyle(); // style
            Font font = workbook.createFont();
//            CellStype.setFillForegroundColor(IndexedColors.PINK.getIndex());
//            CellStype.setFillPattern(FillPatternType.SOLID_FOREGROUND);
            font.setColor(IndexedColors.RED.getIndex());
            CellStype.setFont(font);
            Row testDataRow = sheet.createRow(1);// 套餐标题
            testDataRow.setHeight((short) 800);
            Cell testDataCell0 = testDataRow.createCell(0);
            testDataCell0.setCellValue("新增线下申请务必不填");
            testDataCell0.setCellStyle(CellStype);
            Cell testDataCell1 = testDataRow.createCell(1);
            testDataCell1.setCellValue("xxx试剂盒");
            testDataCell1.setCellStyle(CellStype);
            Cell testDataCell2 = testDataRow.createCell(2);
            testDataCell2.setCellValue("x元");
            testDataCell2.setCellStyle(CellStype);
            Cell testDataCell3 = testDataRow.createCell(3);
            testDataCell3.setCellValue(2);
            testDataCell3.setCellStyle(CellStype);
            Cell testDataCell4 = testDataRow.createCell(4);
            testDataCell4.setCellValue("2x元");
            testDataCell4.setCellStyle(CellStype);
            Cell testDataCell5 = testDataRow.createCell(5);
            testDataCell5.setCellValue("xxx公司");
            testDataCell5.setCellStyle(CellStype);
            Cell testDataCell6 = testDataRow.createCell(6);
            testDataCell6.setCellValue(1365454545);
            testDataCell6.setCellStyle(CellStype);
            Cell testDataCell7 = testDataRow.createCell(7);
            testDataCell7.setCellValue("xxx");
            testDataCell7.setCellStyle(CellStype);
            Cell testDataCell8 = testDataRow.createCell(8);
            testDataCell8.setCellValue("xxx");
            testDataCell8.setCellStyle(CellStype);
            Cell testDataCell9 = testDataRow.createCell(9);
            testDataCell9.setCellValue("xxx");
            testDataCell9.setCellStyle(CellStype);
            Cell testDataCell10 = testDataRow.createCell(10);
            testDataCell10.setCellValue("注意:此行为输入实例,请正式输入商品后删除此行");
            testDataCell10.setCellStyle(CellStype);
            workbook.write(outputStream);
            outputStream.flush();
        } catch (Exception ex) {
            logger.error("下载线下申请模板失败", ex);
        } finally {
            if (outputStream != null) {
                try {
                    outputStream.close();
                } catch (IOException e) {
                    logger.error("下载线下申请模板outputstream关闭失败", e);
                }
            }
        }
    }
<div class="modal fade" id="notice">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class='modal-header'>
                <h4 class="modal-title">上传线下申请注意事项<small></small></h4>
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span></button>

            </div>
            <div class='modal-body'>
                <p>1. 仅上传Excel的第一个sheet,其他sheet会被忽略。</p>
                <p>2. 单次最多上传10000条申请,如果申请数量大于10000,请分几次上传,否则会报错。</p>
                <p>3. 货品名称+供应单位两者均一致的申请视为同一申请,请勿重复上传。</p>
                <p>4. Excel中的单元格【线下申请ID】,不用填写。</p>
                <p>5. 除货号、品牌、规格、备注外,其他线下申请信息为必填。</p>
                <p>6. 上传文件的版本必须为Office excel 2007或以上,即文件扩展名为.xlsx。</p>
                <p>7. 请严格按照标准模板上传文件。</p>
                <form class='hidden'>
                    <input type='file' id='file4excel1'
                           accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel"/>
                </form>
            </div>
            <div class='modal-footer'>
                <button type="button" id="c_add4batch1" class="btn btn-primary " data-loading-text="保存中..."> 批量导入线下申请
                </button>
                <a href='/customer/order/download' type="button" class="btn btn-default">下载标准导入模板</a>
                <button type="button" class="btn btn-danger" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>

一点击html a标签就重定向到登录界面,别的地方我也是这样写的就没有问题

  • 写回答

4条回答 默认 最新

  • du781166309 2021-04-29 15:17
    关注

    评论

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行