Jfinal 验证码问题
// 代码 public void getCaptcha() { renderCaptcha(); }
本地运行正常,正式环境报以下错误
ERROR [http-bio-3081-exec-25] (ActionHandler.java:104) : /getCaptcha
com.jfinal.render.RenderException: java.lang.ArrayIndexOutOfBoundsException: 0
at com.jfinal.captcha.CaptchaRender.render(CaptchaRender.java:97)
at com.jfinal.core.ActionHandler.handle(ActionHandler.java:99)
at com.web.handlers.XssHandler.handle(XssHandler.java:31)
at com.web.handlers.ConstantsHandler.handle(ConstantsHandler.java:29)
at com.jfinal.core.JFinalFilter.doFilter(JFinalFilter.java:73)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:620)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1152)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:622)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 0
at sun.font.CompositeFont.getSlotFont(CompositeFont.java:333)
at sun.font.CompositeGlyphMapper.initMapper(CompositeGlyphMapper.java:81)
at sun.font.CompositeGlyphMapper.<init>(CompositeGlyphMapper.java:62)
at sun.font.CompositeFont.getMapper(CompositeFont.java:391)
at sun.font.GlyphList.mapChars(GlyphList.java:269)
at sun.font.GlyphList.setFromString(GlyphList.java:244)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:71)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2887)
at com.jfinal.captcha.CaptchaRender.drawGraphic(CaptchaRender.java:153)
at com.jfinal.captcha.CaptchaRender.render(CaptchaRender.java:88)
... 20 more
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应该是你的 linux 不支持某些字体造成的
初步判断是服务器Linux版本为CentOS7.4 字体问题导致
自定义一个 class MyCaptchaRender extends CaptchaRender, 改改那个字体数组,然后用的时候:
render(new MyCaptcharender()) 即可