This parser does not support specification "null" version "null"异常处理

这个异常出现后,其实就是jar包的原因,
xercesImpl和xerces只能有一个包,并且版本可能有要求。
其他的原因以后发现再补充。
我用这个主要就是用于导出excel文件(使用模板),目前来看使用模板是最简单的导出方式。
模板:
模板里面的内容

private void export(List<GridWholeTCA> list, HttpServletRequest request,HttpServletResponse response) throws Exception{
        //获得模版
        String tempFileName = request.getSession().getServletContext().getRealPath("/template");
        //将结果放入这个list中
        List values = new ArrayList();
        Map beans = new HashMap();
        Date date = new Date();
        SimpleDateFormat simpl = new SimpleDateFormat("yyyyMMddHHmmss");
        String currntTime = simpl.format(date);
        tempFileName += "/gridWholeTCA.xls";

        //导出列表名
        String fileName = currntTime+"列表";
        values.add(list);
        beans.put("values", values);

        //文件名称统一编码格式
        fileName = URLEncoder.encode(fileName, "utf-8");

        //生成的导出文件
        File destFile = File.createTempFile(fileName, ".xls");

        //transformer转到Excel
        XLSTransformer transformer = new XLSTransformer();

        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            //将数据添加到模版中生成新的文件
            transformer.transformXLS(tempFileName, beans, destFile.getAbsolutePath());
            //将文件输入
            InputStream inputStream = new FileInputStream(destFile);
            // 设置response参数,可以打开下载页面
            response.reset();
            //设置响应文本格式
            response.setContentType("application/vnd.ms-excel;charset=utf-8");
            response.setHeader("Content-Disposition",
                    "attachment;filename=" + new String((fileName + ".xls").getBytes(), "iso-8859-1"));
            //将文件输出到页面
            ServletOutputStream out = response.getOutputStream();
            bis = new BufferedInputStream(inputStream);
            bos = new BufferedOutputStream(out);
            byte[] buff = new byte[2048];
            int bytesRead;
            // 根据读取并写入
            while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
                bos.write(buff, 0, bytesRead);
            }
        } catch (ParsePropertyException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvalidFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }finally {
            //使用完成后关闭流
            try {
                if (bis != null)
                    bis.close();
                if (bos != null)
                    bos.close();
            } catch (IOException e) {
            }

        }
    }
  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
Parser is not defined 是一个常见的错误消息,它意味着在代码中尝试使用一个未定义的解析器。根据提供的引用信息,这个错误可能与 JavaScript 或 Python 相关。 首先,我们来看看 JavaScript 方面的解决方法。根据 中提到的错误消息,如果你遇到 ReferenceError: X2JS is not defined 的错误,解决方法是在 package.json 文件中使用 angular-x2js-wrapper 来替换对 angular-x2js 的依赖,并相应地更新 Angular 依赖注入。具体操作可以参考该引用中提到的代码示例。 如果问题涉及到 Python,那么根据 中提到的错误消息,产生这个问题的原因是 rqt_graph 用到了 pydot,而 pydot 默认版本只支持 pyparsing < 2.0 版本。而现在系统中 pyparsing 的默认版本是大于 2.0 的。解决方法是升级 pydot 的版本,可以通过运行以下命令来升级 pydot:sudo pip install -U pydot。 综上所述,要解决 Parser is not defined 的问题,你需要根据具体情况来确定是 JavaScript 还是 Python,并根据相应的解决方法进行处理。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [angular-x2js-wrapper:X2JS angularJS 包装器](https://download.csdn.net/download/weixin_42142062/19237735)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [安装html-webpack-plugin插件打包文件后报错 ERROR in Error: document is not defined](https://blog.csdn.net/weixin_53317758/article/details/127090082)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [rqt_graph报错global name 'dot_parser' is not defined](https://blog.csdn.net/bluewhalerobot/article/details/79147086)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

丿失刀丨

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

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

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

打赏作者

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

抵扣说明:

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

余额充值