blob: 3368798369f46196dd9ba36110c1f5e42fa313a6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
package com.juick.www.configuration;
import com.juick.configuration.DataConfiguration;
import com.juick.configuration.SearchConfiguration;
import org.apache.commons.lang3.CharEncoding;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
import javax.servlet.FilterRegistration;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
/**
* Created by aalexeev on 11/20/16.
*/
public class WwwInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override
protected Class<?>[] getRootConfigClasses() {
return new Class<?>[]{
WebAppConfiguration.class,
DataConfiguration.class,
SearchConfiguration.class,
WebSecurityConfig.class};
}
@Override
protected Class<?>[] getServletConfigClasses() {
return new Class<?>[]{WwwServletConfiguration.class};
}
@Override
protected String[] getServletMappings() {
return new String[]{"/"};
}
@Override
protected String getServletName() {
return "WWW-spring dispatcher servlet";
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
FilterRegistration.Dynamic registration = servletContext.addFilter(
"encodingFilter", new CharacterEncodingFilter(CharEncoding.UTF_8, true));
registration.addMappingForUrlPatterns(null, true, "/*");
}
}
|