zoukankan      html  css  js  c++  java
  • 问题记录

    1.自定义异常处理问题

    封装的接口幂等性工具使用aop+自定义注解实现,在执行切入点部分的异常捕获出现问题。
    问题代码:

                try {
                    return pjp.proceed();
                }catch (Throwable throwable) {
                    log.info("系统异常", throwable);
                    String msg = "系统异常";
                    if(StringUtil.isNotEmpty(throwable.getMessage())){
                        msg =  throwable.getMessage();
                    }
                    throw new RuntimeException(msg);
               }
    

    问题: Object proceed() throws Throwable; proceed方法抛出的是异常的顶级父类Throwable
    直接对Throwable 进行捕获会将系统中抛出的业务异常,也转换成了RuntimeException
    统一异常处理中配置了 针对业务异常返回给前端特定的 code的Resutlt

    解决:应该在捕获Throwable 之前,对业务异常进行捕获

                try {              
                    return pjp.proceed();
                } catch(ServiceException e){
                    throw e;
                }catch (Throwable throwable) {
                    log.info("系统异常", throwable);
                    String msg = "系统异常";
                    if(StringUtil.isNotEmpty(throwable.getMessage())){
                        msg =  throwable.getMessage();
                    }
                    throw new RuntimeException(msg);
                }
    

    2.itext生成PDF问题

    电子签约项目需要在后台生成PDF使用的工具包是

            <dependency>
                <groupId>com.itextpdf</groupId>
                <artifactId>itextpdf</artifactId>
                <version>5.5.12</version>
            </dependency>
    

    期间遇到的问题就是产品设计的PDF模板上需要 显示

    复选框勾选字符,使用PDF的html组件过于繁琐

    通过特殊字体实现,百度得知字体为 Windings2 ,通过下载该字体ttf

    来加载字体就可任意通过纯文本来实现

    BaseFont symbol = BaseFont.createFont(
                        "static/font/wingdings2.ttf", com.lowagie.text.pdf.BaseFont.IDENTITY_H, com.lowagie.text.pdf.BaseFont.NOT_EMBEDDED);
    
  • 相关阅读:
    【WPF on .NET Core 3.0】 Stylet演示项目
    【WPF on .NET Core 3.0】 Stylet演示项目
    [译]ABP v1.0终于发布了!
    Centos7 安装配置 Rabbitmq Cluster
    新系统添加sshkey/pexpect基本使用
    ansible Templates
    Jenkins Sonar
    Haproxy 安装及配置
    keepalived 安装及配置
    docker etcd
  • 原文地址:https://www.cnblogs.com/shinyrou/p/13672076.html
Copyright © 2011-2022 走看看