SpringBoot2.x锝淭hymeleaf椤甸潰涓嶈兘姝e父杞藉叆css銆乯s鏂囦欢

匿名 (未验证) 提交于 2019-12-02 16:45:31

1銆佸疄鐜板疄鐜癢ebMvcConfig閰嶇疆绫诲彲浠ヨВ鍐抽〉闈笉鑳藉姞杞絚ss,js鐨勯棶棰橈紱

 1 package com.bie.config;  2   3 import org.springframework.context.annotation.Configuration;  4 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;  5 import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;  6 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;  7   8 /**  9  * 10  */ 11 @Configuration 12 public class SpringMvcWebConfigSupport implements WebMvcConfigurer { 13  14     /** 15      * 榛樿璁块棶鐨勬槸棣栭〉 16      * @param registry 17      */ 18     @Override 19     public void addViewControllers(ViewControllerRegistry registry) { 20         registry.addViewController("/").setViewName("index"); 21         registry.addViewController("/index.html").setViewName("index"); 22     } 23  24     /** 25      * 灏唖tatic涓嬮潰鐨刯s锛宑ss鏂囦欢鍔犺浇鍑烘潵 26      * @param registry 27      */ 28     @Override 29     public void addResourceHandlers(ResourceHandlerRegistry registry) { 30         //registry.addResourceHandler("/static/").addResourceLocations("classpath:/static/"); 31         registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/"); 32     } 33 }

鍥犱负鍦⊿pringBoot鐨?.x鏂扮増鏈腑WebMvcConfigurerAdapter 锛堜娇鐢╓ebMvcConfigurerAdapter鍙互鏉ユ墿灞昐pringMVC鐨勫姛鑳斤級閰嶇疆绫诲凡缁忎笉鎺ㄨ崘浣跨敤浜嗭紝鍙互浣跨敤WebMvcConfigurer 鎴栬€匴ebMvcConfigurationSupport鏉ラ厤缃嚜宸辩殑閰嶇疆淇℃伅銆侟/span>

 1 //package com.bie.config;  2 //  3 //import org.springframework.context.annotation.Configuration;  4 //import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;  5 //import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;  6 //  7 ///**  8 // * WebMvcConfigurerAdapter绫诲凡缁忎笉鎺ㄨ崘浣跨敤浜  9 // */ 10 //@Configuration 11 //public class SpringMvcWebConfig extends WebMvcConfigurerAdapter { 12 // 13 ////    @Override 14 ////    public void addViewControllers(ViewControllerRegistry registry) { 15 ////        //娴忚鍣ㄥ彂閫佽姹傚埌鍒版寚瀹氱殑椤甸潰 16 ////        registry.addViewController("/").setViewName("index"); 17 ////    } 18 // 19 //    public WebMvcConfigurerAdapter webMvcConfigurerAdapter(){ 20 //        WebMvcConfigurerAdapter adapter = new WebMvcConfigurerAdapter(){ 21 //            @Override 22 //            public void addViewControllers(ViewControllerRegistry registry) { 23 //                registry.addViewController("/").setViewName("index"); 24 //            } 25 //        }; 26 //        return adapter; 27 //    } 28 //}

寰呯画......

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!