2014-07-15 2 views
0

저는 웹 개발에 익숙하지 않고 최신 작업을 사용하려면 backbonesjs와 requirejs를 프론트 엔드에 사용하고 백엔드에 스프링 부트를 사용해야합니다. 로그인 페이지 2 개를 제공해야합니다. 템플릿 및 인증 성공 후 나는 내 사용자 이름과 암호를 logedin user.I 표시 할 것입니다 index.html 표시 해야하는 내 loginview 아약스를 사용하여 loginform submitt 수 있으며 해당 인증을 index1.html.But 제공하고 싶습니다. windows.location.href를 수행하면 index.html이 제공되지 않습니다. 봄 보안이 다시 같은 페이지로 리디렉션되는 것 같습니다. 어떻게 구현할 수 있습니까?단일 페이지 응용 프로그램의 스프링 보안

답변

1

어쩌면 도움이됩니다.

스프링 3 with xml.

두 페이지가 있습니다. 이것들은 login과 index jsp입니다.

  • 스프링 웹 보안 구성자는 다음과 같이 구성합니다. @Override protected void configure(HttpSecurity http) throws Exception{ http.exceptionHandling(). accessDeniedPage("/login?accessDeniedError=1").and(). authorizeRequests().anyRequest().authenticated().and(). formLogin().loginPage("/login"). defaultSuccessUrl("/index", true). failureUrl("/login?authenticationFailure").permitAll().and(). logout().deleteCookies("JSESSIONID"). invalidateHttpSession(true).permitAll(); }
  • 스프링 MVC 컨트롤러의 방법은 다음과 같습니다 @RequestMapping(value = "/login", method = RequestMethod.GET) public String login(ModelMap model, HttpServletRequest request){ //business logic return "login"; } @RequestMapping(value = "/index", method = RequestMethod.GET) public String index(ModelMap model, Principal principal, HttpServletRequest request){ //business logic return "index"; }
관련 문제