package com.iailab.module.data.common.utils; import javax.annotation.Resource; import org.springframework.stereotype.Component; import javax.script.ScriptEngine; import javax.script.ScriptException; /** * @author PanZhibao * @date 2021年06月04日 16:01 */ @Component public class JavaScriptHandler { @Resource ScriptEngine scriptEngine; public String eval (String script) { try { return scriptEngine.eval(script).toString(); } catch (ScriptException e) { e.printStackTrace(); return null; } } }