一、
二、
使用范例:
public static void main(String[] args) { // while(true) { // long totalMemory = Runtime.getRuntime().totalMemory() / 1024 / 1024; // long maxMemory = Runtime.getRuntime().maxMemory() / 1024 / 1024; // System.out.println(totalMemory + "M"); // System.out.println(maxMemory + "M"); // } EvaluationContext context = new StandardEvaluationContext(); ExpressionParser parser = new SpelExpressionParser(); Person person = new Person("Tom", 18); context.setVariable("person", person); String v = parser.parseExpression("他的名字为#{#person.name}", new TemplateParserContext()).getValue(context, String.class); // 他的名字为Tom System.out.println(v); } static class Person { private String name; private int age; public Person(String name, int age) { super(); this.name = name; this.age = age; } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } }