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项目即可
    
  • 相关阅读:
    各种机器学习方法概念
    深入理解拉格朗日乘子法(Lagrange Multiplier) 和KKT条件
    肤色识别
    创建自己的窗口消息
    模糊C均值
    Fisher线性判别
    用遗传算法加强足球游戏的人工智能
    人工智能-遗传算法解决推箱子问题现实
    LBP特征
    VC 制作系统托盘程序实现将窗口最小化到系统托
  • 原文地址:https://www.cnblogs.com/wangyang0210/p/11428634.html
Copyright © 2011-2022 走看看