zoukankan      html  css  js  c++  java
  • Java——CaptchaUtil生成二维码乱码

    前言

    这个问题就是因为Linux上没有字体,你可以有两种方法,一个在生成的时候设置字体,一个就是安装字体。
    默认的字体为Courier

    乱码情况

    步骤

    安装字体工具

    yum install -y fontconfig mkfontscale
    

    查看服务器字体

    # fc-list
    /usr/share/fonts/dejavu/DejaVuSansCondensed-Oblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Oblique,Oblique
    /usr/share/fonts/dejavu/DejaVuSansCondensed-Bold.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold,Bold
    /usr/share/fonts/dejavu/DejaVuSans.ttf: DejaVu Sans:style=Book
    /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf: DejaVu Sans:style=Bold
    /usr/share/fonts/dejavu/DejaVuSansCondensed.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed,Book
    /usr/share/fonts/dejavu/DejaVuSans-ExtraLight.ttf: DejaVu Sans,DejaVu Sans Light:style=ExtraLight
    /usr/share/fonts/dejavu/DejaVuSansCondensed-BoldOblique.ttf: DejaVu Sans,DejaVu Sans Condensed:style=Condensed Bold Oblique,Bold Oblique
    /usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
    /usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf: DejaVu Sans:style=Bold Oblique
    

    寻找对应的字体并上传到服务器字体文件目录下

    缓存下字体

    #fc-cache /usr/share/fonts/lyx
    

    拷贝到jdk并缓存

    拷贝字体文件到  jdk安装目录/jre/lib/fonts 目录下
    运行命令  fc-cache jdk安装目录/jre/lib/fonts
    

    重启项目

    重启java项目即可
    
  • 相关阅读:
    04、图的基本考点
    06、排序【应用篇】
    07、顺序表编程考点
    08、单链表编程考点
    04、css position 属性
    03、css float 浮动属性
    02、线性表基础考点
    软件工程博客---小学期--日报6
    软件工程博客---小学期--日报5(含周末)
    软件工程博客---小学期--日报4
  • 原文地址:https://www.cnblogs.com/wangyang0210/p/11428634.html
Copyright © 2011-2022 走看看