Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
sunhaoyuan 2018-04-24 22:52:28 +08:00
commit 1869af9e0a
2 changed files with 27 additions and 2 deletions

View File

@ -90,7 +90,7 @@ public class DruidConfig {
servletRegistrationBean.setInitParameters(initParameters);
return servletRegistrationBean;
}
/*
@Bean
public DruidStatInterceptor getDruidStatInterceptor(){
return new DruidStatInterceptor();
@ -103,6 +103,6 @@ public class DruidConfig {
String[] str={"com.len.service.*","com.len.mapper.*"};
pointcut.setPatterns(str);
return pointcut;
}*/
}
}

View File

@ -12,6 +12,7 @@ import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
import org.springframework.beans.factory.annotation.Value;
@ -23,10 +24,14 @@ import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.ui.freemarker.FreeMarkerConfigurationFactory;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
@ -65,4 +70,24 @@ public class WebMvcConfig extends WebMvcConfigurerAdapter {
registry.addResourceHandler("/images/**").addResourceLocations("file:"+imagePath);
registry.addResourceHandler("/file/**").addResourceLocations("file:"+imagePath);
}
/*保留国际化*/
@Bean
public LocaleChangeInterceptor interceptor() {
LocaleChangeInterceptor interceptor = new LocaleChangeInterceptor();
interceptor.setParamName("lang");
return interceptor;
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(interceptor());
}
@Bean
public LocaleResolver resolver(){
SessionLocaleResolver resolver=new SessionLocaleResolver();
resolver.setDefaultLocale(Locale.US);
return resolver;
}
}