提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.common.utils; |
H |
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
import org.springframework.stereotype.Component; |
|
5 |
|
|
6 |
import javax.script.ScriptEngine; |
|
7 |
import javax.script.ScriptException; |
|
8 |
|
|
9 |
/** |
|
10 |
* @author PanZhibao |
|
11 |
* @date 2021年06月04日 16:01 |
|
12 |
*/ |
|
13 |
@Component |
|
14 |
public class JavaScriptHandler { |
|
15 |
|
|
16 |
@Resource |
|
17 |
ScriptEngine scriptEngine; |
|
18 |
|
|
19 |
public String eval (String script) { |
|
20 |
try { |
|
21 |
return scriptEngine.eval(script).toString(); |
|
22 |
} catch (ScriptException e) { |
|
23 |
e.printStackTrace(); |
|
24 |
return null; |
|
25 |
} |
|
26 |
} |
|
27 |
} |