I need to add a listener to my Spring download application, in web.xml it looks like
<listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener>
I am using the no-web.xml configuration, so I have a class like
public class AppFilterConfig extends AbstractAnnotationConfigDispatcherServletInitializer { @Override protected Filter[] getServletFilters() { CharacterEncodingFilter filter = new CharacterEncodingFilter(); filter.setEncoding("UTF8"); filter.setForceEncoding(true); Filter[] filters = new Filter[1]; filters[0] = filter; return filters; } private int maxUploadSizeInMb = 5 * 1024 * 1024;
As you can see from the above code, I added a listener to the onStartup method (ServletContext servletContext), but this does not help, since I still get
In this case, use RequestContextListener or RequestContextFilter to expose the current request.
this post. How can I correctly add a listener to my Spring boot application?
source share