关于centos7字体缺失导致项目验证码丢失报错500问题

这个问题是这样的,迁移架构的时候项目验证码刷不出来, 页面报错500, 就像下面那样。

tomcat报错是数组越界, 看下面

最诡异的是, 开发那边再三确定代码里面没有问题, 于是我试了一下把war包放在win7下tomcat跑, 见鬼了, 一切正常, 验证码也正常显示。

于是开始折腾。。。

后来找到一篇文章, 里面的说法是这样的,这里引用一下:https://blog.csdn.net/sxg0728/article/details/78459414

 

再看一下我的越界报错

正中下怀了,这里面说的是改代码 , 换个想法就是说, 没有这种中文字体。那解决方法就是把中文字体扔上来不就行了吗。

linux字体保存在/usr/share/fonts下

mkdir /usr/share/fonts/chinese

然后把win7下的C:\Windows\Fonts字体打个包扔上来,放进这个chinese目录下。

给它一个权限

chmod -R 755 /usr/share/fonts/chinese

最后修改一下配置,把刚添加的字体嵌进去。

vim /etc/fonts/fonts.conf

展示一下, 在Font directory list模块下加入<dir>/usr/share/fonts/chinese</dir>

<!-- Font directory list -->

        <dir>/usr/share/fonts</dir>
        <dir>/usr/share/X11/fonts/Type1</dir> <dir>/usr/share/X11/fonts/TTF</dir> <dir>/usr/local/share/fonts</dir>
        <dir prefix="xdg">fonts</dir>
        <dir>/usr/share/fonts/chinese</dir>
        <!-- the following element will be removed in the future -->
        <dir>~/.fonts</dir>

<!--

执行命令,就能看到刚才加进来的字体了。

fc-cache && fc-list

 刷新一下网页,验证码显示正常。

 

posted @ 2019-01-07 09:47  扶苏公子x  阅读(1037)  评论(0编辑  收藏  举报