zoukankan      html  css  js  c++  java
  • 2020-02-24

    庚子鼠年 戊寅月 丁酉日

    描述

    springboot练习

    随笔

    thymeleaf学习

    MVC配置原理

    国际化

    Spring 5.0后,WebMvcConfigurerAdapter被废弃,取代的方法有两种:

    ​ ①implements WebMvcConfigurer(官方推荐)

    ​ ②extends WebMvcConfigurationSupport

    总结博客: https://blog.csdn.net/qq_40674583/article/details/104477435

    拦截器

    1. 实现拦截器接口 HandlerInterceptor

    import org.springframework.stereotype.Component;
    import org.springframework.web.servlet.HandlerInterceptor;
    
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    @Component
    public class LoginHandlerInterceptor implements HandlerInterceptor {
    
        @Override
        public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
    
            System.out.println("拦截器!!!");
            String a = request.getParameter("a");
            // return !StringUtils.isEmpty(a) && "123".equals(a);
            return true;
        }
    }
    

    2. 配置

    import org.springframework.beans.factory.annotation.Autowired;
    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.WebMvcConfigurer;
    
    
    @Configuration
    public class MyMvcConfig implements WebMvcConfigurer {
    
        @Autowired
        LoginHandlerInterceptor loginHandlerInterceptor;
    
        @Override
        public void addInterceptors(InterceptorRegistry registry) {
      registry.addInterceptor(loginHandlerInterceptor).addPathPatterns("/hello");
        }
    }
    

    404处理

    1. 在static项目新建文件夹error

    2. 编写404.html 和 500.html

    3. 配置文件过滤

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry
                .addResourceHandler("/**")
                .addResourceLocations("classpath:/static/");
    }
    

    自定义异常处理

    技术博客https://blog.csdn.net/qq_40674583/article/details/104484838

    自定义类型转换器

    技术博客https://blog.csdn.net/qq_40674583/article/details/104486783

    整合Druid

    整合mybatis

    spring安全

    swagger

    异步任务

    邮件任务

    分布式RPC

    微服务

    Dubbo和Zookeeper

    Dubbo-admin

  • 相关阅读:
    div定位
    学习进度条(第十周)
    学习进度条(第九周)
    软件工程个人作业--找水王
    个人NABCD
    梦断代码阅读笔记01---死定了
    进度条(第八周)
    学习进度条(第七周)
    软件工程结对开发作业02---二维数组求最大连通子数组
    软件工程结对作业01--四则运算Web版
  • 原文地址:https://www.cnblogs.com/chang1024/p/12359154.html
Copyright © 2011-2022 走看看