【FAQ问题记录】 File "/webpage/a/mds/mdsquota/mdsQuotaDetail/template.jsp" not found

本文详细解析了ERP系统中模板下载功能的控制台报错原因,指出因controller中重复使用response响应导致的问题,并提供了修改代码以解决该错误的具体方案。

 在开发ERP系统下载模板问题时,控制台报错如下:

     File "/webpage/a/mds/mdsquota/mdsQuotaDetail/template.jsp" not found

   出现这个问题的原因是因为controller中用了两次response响应到前台来。

 出错前代码如下:

@RequiresPermissions("mds:mdsquota:mdsQuota:import")
	@RequestMapping(value = "template")
	public String  getFileTemplate(String id,HttpServletResponse response,RedirectAttributes redirectAttributes) {
		try {
			String fileName ="材料定额数据导入模板.xlsx";
			String title="红色字体为必填字段,序号和单台定额必须为整数,备注信息不能超过50个字";
			List<String > headerList = new ArrayList<>();
			//示例数据
			List<String> exampleList = new ArrayList<>();
			new ExportExcel().insertList(headerList, exampleList).createExcel(title,headerList,exampleList).write(response,fileName).dispose();
			addMessage(redirectAttributes,"模板下载成功");
		} catch (Exception e) {
			addMessage(redirectAttributes,"模板下载失败!失败信息:"+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/mds/mdsquota/mdsQuota/edit?id="+id;
	}

    在这段代码中 最后发起转发前,程序已经通过response(new ExportExcel().insertList(headerList, exampleList).createExcel(title,headerList,exampleList).write(response,fileName).dispose();),响应到了前端,所以发生了控制台那样的报错。

        最后还是在转发之前发通过return null,解决的报错。

@RequiresPermissions("mds:mdsquota:mdsQuota:import")
	@RequestMapping(value = "template")
	public String  getFileTemplate(String id,HttpServletResponse response,RedirectAttributes redirectAttributes) {
		try {
			String fileName ="材料定额数据导入模板.xlsx";
			String title="红色字体为必填字段,序号和单台定额必须为整数,备注信息不能超过50个字";
			List<String > headerList = new ArrayList<>();
			//示例数据
			List<String> exampleList = new ArrayList<>();
			new ExportExcel().insertList(headerList, exampleList).createExcel(title,headerList,exampleList).write(response,fileName).dispose();
			addMessage(redirectAttributes,"模板下载成功");
                   return null;
		} catch (Exception e) {
			addMessage(redirectAttributes,"模板下载失败!失败信息:"+e.getMessage());
		}
		return "redirect:"+Global.getAdminPath()+"/mds/mdsquota/mdsQuota/edit?id="+id;
	}

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值