thymeleaf3.0+springmvc4 自定义方言后 th标签就无法被解析出来了

1352040452 发布于 2019/06/13 16:25
阅读 193
收藏 0
<bean id="dialect" class="com.jace.wsite.common.thymeleaf.WorkFocusDialect">
   <property name="factory" ref="workFocusExpressionFactory"/>
</bean>
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
   <property name="templateResolver" ref="templateResolver"/>
   <property name="enableSpringELCompiler" value="true"/>
   <property name="dialect" ref="dialect"/>
</bean>

***

package com.jace.wsite.common.thymeleaf;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.thymeleaf.context.IExpressionContext;
import org.thymeleaf.expression.IExpressionObjectFactory;


import java.util.Map;
import java.util.Set;

@Component(value = "workFocusExpressionFactory")
public class WorkFocusExpressionFactory implements IExpressionObjectFactory {
    @Autowired
    private Map<String,DialectBase> maps;

    public WorkFocusExpressionFactory(){
        super();
    }
    @Override
    public Set<String> getAllExpressionObjectNames() {
        return maps!=null?maps.keySet():null;
    }

    @Override
    public Object buildObject(IExpressionContext context, String expressionObjectName) {
        return maps.get(expressionObjectName);
    }

    @Override
    public boolean isCacheable(String expressionObjectName) {
        return false;
    }
}
加载中
返回顶部
顶部