REQ-2135: use fixed mode

This commit is contained in:
yanglin 2024-04-01 15:43:58 +08:00
parent 5ad83c630d
commit c7a0297354

View File

@ -9,6 +9,8 @@ import org.springframework.expression.Expression;
import org.springframework.expression.PropertyAccessor;
import org.springframework.expression.TypedValue;
import org.springframework.expression.common.TemplateParserContext;
import org.springframework.expression.spel.SpelCompilerMode;
import org.springframework.expression.spel.SpelParserConfiguration;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.ReflectivePropertyAccessor;
import org.springframework.expression.spel.support.StandardEvaluationContext;
@ -42,7 +44,9 @@ public class TemplateParser {
evalContext.addPropertyAccessor(new ReflectivePropertyAccessor(false));
evalContext.addPropertyAccessor(NullPropertyAccessor.INSTANCE);
TemplateParserContext templateContext = new TemplateParserContext(openToken, closeToken);
Expression exp = new SpelExpressionParser().parseExpression(expression, templateContext);
SpelParserConfiguration parseCfg = new SpelParserConfiguration(
SpelCompilerMode.MIXED, TemplateParser.class.getClassLoader());
Expression exp = new SpelExpressionParser(parseCfg).parseExpression(expression, templateContext);
exp.getValue(evalContext, String.class);
Object value = exp.getValue(evalContext);
if (value == null)