Code Monkey home page Code Monkey logo

spring-boot-lab's Introduction

spring-boot 相关功能汇总学习

web开发

servlet相关

通过API方式实现注册Servlet,Filter,Linster

  1. 实现Servlet组件相关接口
public class ApiServlet extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)

    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    }
}
  1. 通过ServletRegistrationBean加载Servlet组件
    @Bean
    public ServletRegistrationBean servletRegistrationBean(){
        ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();
        servletRegistrationBean.setName("ApiServlet");
        servletRegistrationBean.setServlet(new ApiServlet());
        servletRegistrationBean.addUrlMappings("/api/servlet/*");
        servletRegistrationBean.addInitParameter("initParam1","initValue1");
        servletRegistrationBean.setAsyncSupported(true);
        return  servletRegistrationBean;
    }

通过Servlet3.0注解方式实现注册Servlet,Filter,Linster

  1. 增加ServletComponentScan扫描入口
@ServletComponentScan(basePackages = "com.github.evan.springboot.web.servlet.annotation")
  1. 实现Servlet组件相关接口

添加相关注解

  • @WebServlet
  • @WebFilter
  • @WebListener
  • @WebInitParam
@WebServlet(name = "AnnoServlet", urlPatterns = "/annotaion/servlet/*",
        initParams = {
             @WebInitParam(name = "initParam1", value = "initValue1"),
             @WebInitParam(name = "initParam2", value = "initValue2")
            }
)
public class AnnoServlet extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    }
}

Spring MVC相关

请求参数获取

响应结果处理

重定向

异常处理

???

  • ContentNegotiatingViewResolver
  • BeanNameViewResolver
  • ConfigurableWebBindingInitializer
  • WebMvcRegistrations
  • HttpMessageConverters
  • MessageCodesResolver
  • Welcome Page 静态和模板页面(index.html)
  • Custom Favicon
  • 内容协商
  • WebBindingInitializer

注解

spring.mvc.static-path-pattern=/resources/**
spring.mvc.format.date-time=yyyy-MM-dd HH:mm:ss

数据库

数据库连接

  • 多数据源
  • druid数据库连接池
  • 内置数据HikariCp tomacat dbcp2
  • JNDI

嵌入式数据库

  • H2
  • HSQL
  • Derby

Spring Framework JdbcTemplate

spring.data.template.*

Spring Data JPA

Mybatis

通用MyBatis 框架

spring-boot-lab's People

Contributors

evan009 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.