fix:fixed the engine.eval() return double or Integer result in ArithmeticCaptchaAbstract.java

This commit is contained in:
wangmingcan 2020-08-21 10:28:17 +08:00
parent da3501451b
commit 1b851f198a

View File

@ -39,7 +39,7 @@ public abstract class ArithmeticCaptchaAbstract extends Captcha {
ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("javascript"); ScriptEngine engine = manager.getEngineByName("javascript");
try { try {
chars = String.valueOf(engine.eval(sb.toString().replaceAll("x", "*"))); chars = String.valueOf(engine.eval(sb.toString().replaceAll("x", "*"))).split("\\.")[0];
} catch (ScriptException e) { } catch (ScriptException e) {
e.printStackTrace(); e.printStackTrace();
} }