控制器重定向/前进在弹簧mvc 3.2与瓦片2不起作用

时间:2014-10-17 05:51:35

标签: spring spring-mvc spring-security tiles

这是场景,用户进入登录页面,用户注册到应用程序,应用程序记录新用户,然后应用程序重定向/转发用户进行身份验证,处理程序方法在同一个控制器中。

问题是转发没有重定向到视图图块,而视图图块被称为“仪表板”。代码下方:

注册过程

 @RequestMapping(value = "/signup", method = RequestMethod.POST)
  public String signup(HttpServletRequest request, HttpServletResponse response, @Valid SignupForm signupForm, BindingResult result, Model model) throws IOException, ServletException {
        String language= Utility.getBrowserLanguageCode( request.getHeader("Accept-Language") );
//      userService.saveSignUp(signupForm, language);
    LoginForm loginForm= new LoginForm();
    loginForm.setJ_username(signupForm.getNewUserId());
    loginForm.setJ_password(signupForm.getNewUserPassword());   

    request.removeAttribute("signupForm");
    request.setAttribute("loginForm", loginForm);

    return "forward:/login";    // Also, I tried with redirect with the same result :(
  }  

转发/重定向到

    //----- login called on submit the user credentials.
  @RequestMapping(value = "/login", method = RequestMethod.POST)
  public String customLogin(HttpServletRequest request, HttpServletResponse response, @Valid LoginForm loginForm, BindingResult result, Model model) throws IOException, ServletException {
      // do whatever validation you want to do
      String username = loginForm.getJ_username();
      String password = loginForm.getJ_password();

      return 'dashboard';
  }

这里是瓷砖设置:

  <definition extends="default" name="dashboard">
    <put-attribute name="body" value="/WEB-INF/views/dashboard.jspx"/>
  </definition>

我还有以下安全流程,我看到的是我的过滤器正在调用很多,以下是日志。 (这种情况类似于:Stackoverflow#:20332050

00:19:34,604 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'redirect:/login'
00:19:34,604 DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.RedirectView: name 'redirect:/login'; URL [/login]] in DispatcherServlet with name 'quo'
00:19:34,606 DEBUG org.springframework.security.web.context.HttpSessionSecurityContextRepository - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
00:19:52,130 DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request
00:20:11,960 DEBUG org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter - Closing JPA EntityManager in OpenEntityManagerInViewFilter
00:20:13,497 DEBUG org.springframework.orm.jpa.EntityManagerFactoryUtils - Closing JPA EntityManager
...

23:30:53,685 DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'dashboard'
23:30:53,686 DEBUG org.springframework.web.servlet.DispatcherServlet - Rendering view [org.springframework.web.servlet.view.tiles2.TilesView: name 'dashboard'; URL [dashboard]] in DispatcherServlet with name 'quo'
23:30:53,687 DEBUG org.springframework.web.servlet.view.tiles2.TilesView - Added model object 'loginForm' of type [com.jarbits.security.LoginForm] to request in view with name 'dashboard'
23:30:53,687 DEBUG org.springframework.web.servlet.view.tiles2.TilesView - Added model object 'org.springframework.validation.BindingResult.loginForm' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'dashboard'
23:30:53,687 DEBUG org.springframework.web.servlet.view.tiles2.TilesView - Added model object '_dashboardList' of type [java.util.ArrayList] to request in view with name 'dashboard'
23:30:53,729 DEBUG org.springframework.web.servlet.DispatcherServlet - Successfully completed request

而我所看到的是过滤器正在调用任何东西,并且突然将平铺视图名称更改为&#39; index&#39; (完全如案例20332050)

org.springframework.web.servlet.view.tiles2.TilesView: name 'index'

0 个答案:

没有答案