首页 > 编程语言 > 详细

ViewResolver -Springboot中的视图解析器

时间:2020-04-05 10:34:40      阅读:92      评论:0      收藏:0      [点我收藏+]

项目结构如下(Idea)

技术分享图片

 

 

代码

package com.syu.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.Locale;

//若你想diy一些定制化的功能,只需要写这个组件,然后将它交给SpringBoot
//扩展SpringMVC  dispatchservlet
@Configuration
public class MyMvcConfig implements WebMvcConfigurer {

    //ViewResolver 实现了试图解析器的接口的类,我们就可以把它看作一个视图解析器
    @Bean
    public ViewResolver myViewResolver(){
        return new MyViewResolver();
    }

    public static class MyViewResolver implements ViewResolver{

        @Override
        public View resolveViewName(String s, Locale locale) throws Exception {
            return null;
        }
    }
}

 

ViewResolver -Springboot中的视图解析器

原文:https://www.cnblogs.com/lotus-wmm/p/12635751.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!