Java 1.8을 사용하여 스프링 부트 (1.5.1.RELEASE) 응용 프로그램을 개발했습니다. 맞춤형 사용자 세부 정보 서비스와 함께 봄 보안을 사용하고 있습니다. - 내 응용 프로그램이 올바른 HTML 페이지 /보기를 표시하지 않습니다 성공적인 인증에봄 부팅 응용 프로그램 Null ModelAndView가 반환되었습니다.
, 그것은 로그인 페이지에 남아 이것이 내가 로그에서 볼 것입니다 :
2017-12-15 23:19:43.998 DEBUG 10340 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2017-12-15 23:19:43.998 DEBUG 10340 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Successfully completed request
이것은 내가 많은 일을 한 일입니다 몇 번이나 전에 어떤 일이 있었지만, 이번에는 효과가 없어서 그 이유를 알 수 없으므로 도움이 필요합니다.
이
내 보안 설정 클래스입니다 :@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
/** The Constant LOGIN_PAGE. */
private static final String LOGIN_PAGE = "/login";
/** The Constant AUTHORISED_REQUESTS_ANT_MATCHER. */
private static final String AUTHORISED_REQUESTS_ANT_MATCHER = "/**";
/** The Constant BAD_CREDENTIALS_EXCEPTION_URL. */
private static final String BAD_CREDENTIALS_EXCEPTION_URL = "/login?error";
/** The Constant ACCOUNT_EXPIRED_EXCEPTION_URL. */
private static final String ACCOUNT_EXPIRED_EXCEPTION_URL = "/login?accountexpired";
/** The Constant CREDENTIALS_EXPIRED_EXCEPTION_URL. */
private static final String CREDENTIALS_EXPIRED_EXCEPTION_URL = "/login?credentialsexpired";
/** The Constant ACCOUNT_DISABLED_EXCEPTION_URL. */
private static final String ACCOUNT_DISABLED_EXCEPTION_URL = "/login?accountdisabled";
/** The Constant ACCOUNT_LOCKED_EXCEPTION_URL. */
private static final String ACCOUNT_LOCKED_EXCEPTION_URL = "/login?accountlocked";
/** The find user by username command. */
@Autowired
private Command<FindUserByUsernameResp, FindUserByUsernameParam> findUserByUsernameCommand;
public SecurityConfig() {
super();
}
// ===========================================
// Public Methods
// ===========================================
public Command<FindUserByUsernameResp, FindUserByUsernameParam> getFindUserByUsernameCommand() {
return findUserByUsernameCommand;
}
public void setFindUserByUsernameCommand(Command<FindUserByUsernameResp, FindUserByUsernameParam> findUserByUsernameCommand) {
this.findUserByUsernameCommand = findUserByUsernameCommand;
}
@Bean
public ExceptionMappingAuthenticationFailureHandler exceptionMappingAuthenticationFailureHandler() {
Map<String, String> mappings = new HashMap<String, String>();
mappings.put(BadCredentialsException.class.getCanonicalName(), BAD_CREDENTIALS_EXCEPTION_URL);
mappings.put(AccountExpiredException.class.getCanonicalName(), ACCOUNT_EXPIRED_EXCEPTION_URL);
mappings.put(CredentialsExpiredException.class.getCanonicalName(), CREDENTIALS_EXPIRED_EXCEPTION_URL);
mappings.put(DisabledException.class.getCanonicalName(), ACCOUNT_DISABLED_EXCEPTION_URL);
mappings.put(LockedException.class.getCanonicalName(), ACCOUNT_LOCKED_EXCEPTION_URL);
ExceptionMappingAuthenticationFailureHandler exceptionMappingAuthenticationFailureHandler = new ExceptionMappingAuthenticationFailureHandler();
exceptionMappingAuthenticationFailureHandler.setExceptionMappings(mappings);
return exceptionMappingAuthenticationFailureHandler;
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(new UserDetailsServiceImpl(getFindUserByUsernameCommand()));//.passwordEncoder(new BCryptPasswordEncoder());
}
protected void configure(HttpSecurity http) throws Exception {
http.formLogin().loginPage(LOGIN_PAGE).successForwardUrl("/")
.and()
.authorizeRequests()
.antMatchers(LOGIN_PAGE).permitAll()
.antMatchers(AUTHORISED_REQUESTS_ANT_MATCHER).authenticated();
}
}
그리고 이것은 내 웹 구성입니다 :
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
// ===========================================
// Public Members
// ===========================================
// ===========================================
// Private Members
// ===========================================
/** The Constant ROOT_URL. */
private static final String ROOT_URL = "/";
/** The Constant ROOT_VIEW. */
private static final String ROOT_VIEW = "app/views/index";
/** The Constant LOGIN_URL. */
private static final String LOGIN_URL = "/login";
/** The Constant LOGIN_VIEW. */
private static final String LOGIN_VIEW = "login";
/*
* (non-Javadoc)
*
* @see
* org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
* #addViewControllers(org.springframework.web.servlet.config.annotation.
* ViewControllerRegistry)
*/
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController(ROOT_URL).setViewName(ROOT_VIEW);
registry.addViewController(LOGIN_URL).setViewName(LOGIN_VIEW);
}
}
내가 템플릿 폴더 아래에 내 응용 프로그램에서 두 개의 HTML 페이지를 가지고 있고, 그들이 :
login.html (잘 표시됨) app/views/index.html
내 index.html 파일이 표시되지 않습니다.
아이디어가 있으십니까?