merge
This commit is contained in:
@@ -4,10 +4,12 @@ import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import com.xwbing.handler.LoginInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -56,6 +58,19 @@ public class DispatcherServletConfig extends WebMvcConfigurerAdapter {
|
||||
super.addResourceHandlers(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* 视图配置
|
||||
*
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addViewControllers(ViewControllerRegistry registry) {
|
||||
registry.addViewController("/").setViewName("login.html");
|
||||
//添加更多
|
||||
registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
|
||||
super.addViewControllers(registry);
|
||||
}
|
||||
|
||||
/**
|
||||
* 扩展消息转换器,增加fastjson
|
||||
*
|
||||
|
||||
@@ -18,13 +18,9 @@ public class ServletConfig {
|
||||
private final Logger logger = LoggerFactory.getLogger(ServletConfig.class);
|
||||
|
||||
@Bean
|
||||
public CaptchaServlet captchaServlet() {
|
||||
return new CaptchaServlet();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletRegistrationBean captchaServletRegistrationBean(CaptchaServlet captchaServlet) {
|
||||
public ServletRegistrationBean captchaServletRegistrationBean() {
|
||||
logger.info("注册验证码servlet ======================= ");
|
||||
CaptchaServlet captchaServlet = new CaptchaServlet();
|
||||
ServletRegistrationBean registration = new ServletRegistrationBean(captchaServlet);
|
||||
registration.setEnabled(true);
|
||||
registration.addUrlMappings("/servlet/captcha");
|
||||
|
||||
@@ -26,6 +26,8 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
|
||||
private static final Set<String> set = new HashSet<>();//拦截器白名单
|
||||
|
||||
static {
|
||||
//映射到登录页面,不拦截
|
||||
set.add("/");
|
||||
//验证码
|
||||
set.add("/servlet/captcha");
|
||||
//swagger
|
||||
@@ -33,7 +35,6 @@ public class LoginInterceptor extends HandlerInterceptorAdapter {
|
||||
set.add("/swagger-resources");
|
||||
set.add("/configuration/ui");
|
||||
set.add("/configuration/security");
|
||||
//
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user