在春季4.3.x环境中将thymeleaf从2.x更新到3.x时,我遇到的问题是org.thymeleaf.context.VariablesMap类已被删除。我正在使用以下模型结构
public interface Model extends Map<String, Object>, Serializable {...} public class BaseModel extends VariablesMap<String, Object> implements Model {...}
VariablesMap实现了一个OGNL MapPropertyAccessor,无论是否存在键AlternativeLanguages,该OGNL MapPropertyAccessor都可以使用点符号来访问模型。
${meta.alternativeLanguages}
现在使用thymeleaf 3,spring集成仅使用SpringEL,并且当key AlternativeLanguages不存在时,SpringEL MapAccessor会引发异常
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 28): Property or field 'alternativeLanguages' cannot be found on object of type 'd.v.BaseModel' - maybe not public?
有没有一种方法可以避免将所有模板迁移到
${meta['alternativeLanguages']}
料青山看我应如是
相关分类