其实就是注入

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. python 2.43 升级到2.7

    [root@GW1 bin]# lsb_release -aLSB Version: :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3. ...

  2. Eclipse修改编码格式

    ♣修改工作空间默认编码 ♣修改文件的编码 ♣修改某文件类型的编码 ♣修改JSP文件类型的编码 1.修改工作空间默认编码 window -> preferences ->  General ...

  3. Mac通过终端显示和隐藏 隐藏文件

    defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder //显示隐藏文件 defaults write ...

  4. HTTP Header

    1.User-Agent 记录访问当前网页的用户浏览器类型和版本,操作系统类型和版本.常见场景:根据不同浏览器和版本提供不同站点. JavaScript通过window.navigator.userA ...

  5. 前端页面使用 Json对象与Json字符串之间的互相转换

    前言 在前端页面很多时候都会用到Json这种格式的数据,最近没有前端,后端的我也要什么都要搞,对于Json对象与Json字符串之间的转换终于摸清楚了几种方式,归纳如下! 一:Json对象转换为json ...

  6. 使用PowerShell解三道测试开发笔试题

    在网上看到了三道测试开发的笔试题,答案是用Python解的.这段时间正好在学PowerShell,练习一下:) 1. 验证邮箱格式 2. 获取URL的后缀名 3. 获取前一天时间或前一秒 我的解法是: ...

  7. (js) 输入框只能输入中文、英文、数字、@符号和.符号

    只能输入中文.英文.数字.@符号和.符号<input type="text" onkeyup="value=value.replace(/[^\a-\z\A-\Z0 ...

  8. jar包的MANIFEST.MF注意事项

    1. 基本格式 属性名称:空格+属性值 2. 一行最多72个字符,换行继续必须以空格开头 3. 文件最后必须要有一个回车换行 4. Class-Path 当前路径是jar包所在目录,如果要引用当前目录 ...

  9. ORA-03113: end-of-file on communication channel

    导致的原因,可能是异常断电导致文件状态不一致. SQL> startupORACLE instance started. Total System Global Area 1653518336 ...

  10. VC工程中文件的编译顺序

    用联合编译工具能减少大量编译时间,然而如果工程里有个大型cpp文件,其他文件都编译好了只等着它... 两步解决问题: 1.将大文件分散到多个小cpp里面,加快并发,减少单个文件编译时间 2.优先编译大 ...