diff options
author | Vitaly Takmazov | 2016-06-28 11:09:57 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-06-28 11:09:57 +0300 |
commit | a3b1c3f5ea8248ab9060bc773aa819ca4b090bee (patch) | |
tree | 7216dcee52f985f1e789414050804f7f1b0dd66e /src/main/java/com | |
parent | 331645f0fd7fbe7d9679d39dcce453cc3b2cab6e (diff) |
configure webmvc
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java | 5 | ||||
-rw-r--r-- | src/main/java/com/juick/ws/configuration/WebsocketInitializer.java | 33 |
2 files changed, 37 insertions, 1 deletions
diff --git a/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java index a56e56f5..a298d0a0 100644 --- a/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java +++ b/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java @@ -9,6 +9,8 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.core.env.Environment; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.datasource.DriverManagerDataSource; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.config.annotation.EnableWebSocket; import org.springframework.web.socket.config.annotation.WebSocketConfigurer; @@ -20,10 +22,11 @@ import javax.inject.Inject; * Created by vitalyster on 28.06.2016. */ @Configuration +@EnableWebMvc @EnableWebSocket @ComponentScan(basePackages = {"com.juick"}) @PropertySource("classpath:juick.conf") -public class WebsocketConfiguration implements WebSocketConfigurer { +public class WebsocketConfiguration extends WebMvcConfigurerAdapter implements WebSocketConfigurer { @Inject Environment env; diff --git a/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java b/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java new file mode 100644 index 00000000..89017f8b --- /dev/null +++ b/src/main/java/com/juick/ws/configuration/WebsocketInitializer.java @@ -0,0 +1,33 @@ +package com.juick.ws.configuration; +import org.springframework.web.filter.CharacterEncodingFilter; +import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; + +import javax.servlet.Filter; + +/** + * Created by vt on 09/02/16. + */ +public class WebsocketInitializer extends AbstractAnnotationConfigDispatcherServletInitializer { + @Override + protected Class<?>[] getRootConfigClasses() { + return new Class[] {WebsocketConfiguration.class}; + } + + @Override + protected Class<?>[] getServletConfigClasses() { + return null; + } + + @Override + protected String[] getServletMappings() { + return new String[] { + "/" + }; + } + @Override + protected Filter[] getServletFilters() { + CharacterEncodingFilter characterEncodingFilter = new CharacterEncodingFilter(); + characterEncodingFilter.setEncoding("UTF-8"); + return new Filter[] { characterEncodingFilter}; + } +} |