其实就是注入

FilterRegistrationBean 、
ServletRegistrationBean 、
ServletListenerRegistrationBean

这三个类
 

直接上代码:

    @Bean
public FilterRegistrationBean filterRegistrationBean() {
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter();
characterEncodingFilter.setEncoding("UTF-8");
registrationBean.setFilter(characterEncodingFilter);
return registrationBean;
} @Bean
public ServletRegistrationBean servlet(){
return new ServletRegistrationBean();
} @Bean
public ServletListenerRegistrationBean<EventListener>(){
return new ServletListenerRegistrationBean<>(new EventListener());
}

springboot 注入Servlet,Filter,Listener的方法的更多相关文章

  1. SpringBoot注册Servlet/Filter/Listener

    由于SpringBoot默认是以jar包的方式启动嵌入式的Servlet容器来启动SpringBoot的web应用,那么没有web.xml文件,如何配置我们的三大Web基础组件呢? 通过使用XXXRe ...

  2. SpringBoot学习笔记(6)----SpringBoot中使用Servlet,Filter,Listener的三种方式

    在一般的运用开发中Controller已经大部分都能够实现了,但是也不排除需要自己实现Servlet,Filter,Listener的方式,SpringBoot提供了三种实现方式. 1. 使用Bean ...

  3. ServletContextInitializer添加 servlet filter listener

    ServletContextInitializer添加 servlet filter listener https://www.cnblogs.com/pomer-huang/p/9639322.ht ...

  4. SpringBoot---注册Servlet,Filter,Listener

    1.概述 1.1.当使用  内嵌的Servlet容器(Tomcat.Jetty等)时,将Servlet,Filter,Listener  注册到Servlet容器的方法: 1.1.1.直接注册Bean ...

  5. servlet filter listener interceptor 知识点

    这篇文章主要介绍 servlet filter listener interceptor 之 知识点.博文主要从 概念,生命周期,使命介绍其区别.详情如下:   概念 生命周期 使命 servlet ...

  6. JavaWeb三大组件(Servlet,Filter,Listener 自己整理,初学者可以借鉴一下)

    JavaWeb三大组件(Servlet,Filter,Listener 自己整理,初学者可以借鉴一下) Reference

  7. SpringBoot整合WEB开发--(九)整合Servlet,Filter,Listener

    简介: 如果需要整合第三方框架时,可能还是不得不使用Servlet,Filter,Listener,Springboot中也有提供支持. @WebServlet("/my") pu ...

  8. servlet/filter/listener/interceptor区别与联系

    转自:http://www.cnblogs.com/doit8791/p/4209442.html servlet.filter.listener是配置到web.xml中(web.xml 的加载顺序是 ...

  9. 【转】servlet/filter/listener/interceptor区别与联系

    原文:https://www.cnblogs.com/doit8791/p/4209442.html 一.概念: 1.servlet:servlet是一种运行服务器端的java应用程序,具有独立于平台 ...

随机推荐

  1. 规范和封装jdbc程序代码

    JDBC 部分方法引用工具类 package it.cast.jdbc; import java.sql.Connection; import java.sql.DriverManager; impo ...

  2. oracle TBL$OR$IDX$PART$NUM BUG案例处理过程

    通过AWR报告发现数据库cpu告警的问题,定位产生问题的sql语句 首先查看SQL的执行计划 ) FROM cmds.psn_cntr_holder a ,cmds.pol_attrib c ,cmd ...

  3. Python强化训练笔记(七)——使用deque队列以及将对象保存为文件

    collections模块中的deque对象是一个队列,它有着正常队列的先进先出原则.我们可以利用这个对象来实现数据的保存功能. 例如,现有一个猜数字大小的游戏,系统开始会随机roll点一个0-100 ...

  4. 《UML大战需求分析阅读笔记》05

    在需求分析的阶段,非功能需求也是十分重要的一个阶段.部署图和构件图就能很好的描述非功能需求. 部署图从硬件的角度.物理层次上进行系统的整体规划,包括当前的IT架构以及改造后的IT构架,包括:Node: ...

  5. C#组合查询小Demo

    namespace WindowsFormsApplication1 { public partial class Form1 : Form { string Sql = "select * ...

  6. svn中第一次check out working copy项目下来出现 ld: library not found for -lcrypto clang: error: linker command failed with exit code 1 (use -v to see invocation)

    这个问题主要是.a文件的忽略删除,需要更改设置,并且把文件重新添加

  7. Spark会把数据都载入到内存么

    转载自:https://www.iteblog.com/archives/1648 前言: 很多初学者其实对于Spark的编程模式还是RDD这个概念理解不到位,就会产生一些误解.比如,很多时候我们常常 ...

  8. 使用Qt5.7.0 VS2015版本生成兼容XP的可执行程序 good(从VS2012 update1开始支持xp和c++11)

    一.直接使用VS2012/VS2013/VS2015生成XP兼容的可执行程序 Visual Studio刚发布时没打补丁,称为RTM版,之后会陆续发布补丁,进行bug修复和功能增强.VS2010及之前 ...

  9. 基于Angular2的前端框架CoreUI开发使用说明

    开源地址:https://github.com/mrholek/CoreUI-Free-Bootstrap-Admin-Template/tree/master/Angular2_CLI_Starte ...

  10. GIT使用笔记-fatal:multiple stage entries for merged file处理办法

    该错误是在cherry-pick时出现 无法确定冲突原因 分支无法checkout ,reset等等全都失效 在网上给出的解决办法全部都是 rm .git/index git add -A git c ...