package com.zzwtec.wechat.config;

import com.jfinal.template.ext.spring.JFinalViewResolver;
import org.springframework.web.servlet.View;

import java.util.Locale;

/**
 * @ClassName JFinalViewResolverExt
 * @Author Administrator
 * @Date 2018/12/11 0011 19:55
 */
public class JFinalViewResolverExt extends JFinalViewResolver {

    @Override
    protected View loadView(String viewName, Locale locale) throws Exception {//此方法是无奈之举 暂未找到其他方法替换
        String suffix = getSuffix();
        if (".jsp".equals(suffix) || ".ftl".equals(suffix) || ".vm".equals(suffix) || viewName.contains("community") || viewName.contains("admcommon") ||  viewName.contains("adm") ||viewName.contains("wechat/menu")) {
            return null;
        }else if("error".equals(viewName)){
            return super.loadView("/error.html", locale);
        } else {
            return super.loadView(viewName, locale);
        }
    }
}
