首页>代码>springboot+jpa+bootstrap+mysql用户登录+增删改查 运行环境为IDEA>/springboot-jba/src/main/java/ng/bq/springbootjba/config/MyMvcConfig.java
package ng.bq.springbootjba.config; import ng.bq.springbootjba.component.MyLocalResolver; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.LocaleResolver; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration public class MyMvcConfig extends WebMvcConfigurerAdapter { public void addViewControllers(ViewControllerRegistry registry){ // super.addViewControllers(registry); //浏览器发送 /atguigu请求来到 registry.addViewController("/atguigu").setViewName("success"); } //所有的WebMvcConfiguration组件都会一起起作用 @Bean//将容器注册在容器 public WebMvcConfigurerAdapter webMvcConfigurerAdapter(){ WebMvcConfigurerAdapter adapter = new WebMvcConfigurerAdapter() { @Override public void addViewControllers(ViewControllerRegistry registry) { registry.addViewController("/").setViewName("login"); registry.addViewController("/index.html").setViewName("login"); // registry.addViewController("/main.html").setViewName("dashboard"); } // //注册拦截器 @Override public void addInterceptors(InterceptorRegistry registry) { //super.addInterceptors(registry); // 静态资源 // SpringBoot已经做好静态资源的映射 // registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**") // .excludePathPatterns("/index.html","/","/user/login"); } }; return adapter; } @Bean public LocaleResolver localeResolver(){ return new MyLocalResolver(); } }
最近下载更多
skipple3 LV39
2023年10月25日
飞呀飞呀飞不放 LV7
2023年8月9日
hbsoft2008 LV16
2023年3月21日
lyws1986 LV17
2023年3月13日
微信网友_6368711690080256 LV3
2023年2月28日
zhaoming200677 LV12
2022年12月3日
呵呵哈哈哈 LV10
2022年7月8日
Ty LV10
2022年6月27日
CHENHAOJUDA LV10
2022年6月14日
aqin_qin LV1
2022年6月3日