Announcement Announcement Module
No announcement yet.
How do I redirect from setSuccessView() to a Controller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I redirect from setSuccessView() to a Controller

    Hi guys,

    I use SimpleFormController for a page and after I receive the response I want to redirect to a diferent controller not view. I want to do this only on the server side through setSuccessView(). Can somebody guide me how should I configure my springapp-servlet.xml?

    I want to call from HomeController the bean named: "/".

        <!-- ========================= VIEW DEFINITIONS ========================= -->
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
            <property name="prefix"><value>/WEB-INF/jsp/</value></property>
            <property name="suffix"><value>.jsp</value></property>
    	<!-- ========================= DEFINITIONS OF PUBLIC CONTROLLERS ========================= -->
    	<bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    	<bean name="/" class="web.controller.HomeController">
    	<bean name="/" class="web.controller.SessionStatsStaticController">
    		<property name="incomingPage" value="allUsersList"/>
    		<property name="server" value="Local"/>
    Thanks and regards,
    Last edited by bogdanb; May 10th, 2007, 02:42 AM.

  • #2
    Re : How do I redirect from setSuccessView() to a Controller

    In springapp-servlet.xml
    in definition of HomeController,
    U can define as
    <property name="successview" value="/"/>
    This successview is nothing but setSuccessView().
    It will redirect to another controller as u defined in xml..........



    • #3

      Thanks for reply. I have tried like that, putting directly in the HomeController setSuccessView the bean name. The problem is that my bean does not extend the org.springframework.web.servlet.view.AbstarctView but the Controller, so I get exception when it tries to forward.

      So that's why I put the question because I need a mceanism (not especialy setSuccessView) to direct me on the ServerSide to another controller with all the model available from the coming page.

      Thanks and regards,


      • #4
        I'm reasonably new to this but have you tried using AbstractWizardFormController if what you are trying to achieve is a wizard style form? There is a small tutorial on how to use it in the Manning book (Spring in Action).


        • #5
          You can use "redirect:controllername.htm" as your view name as:

          <property name="successView" value="" />


          • #6
            Re : successView

            <property name="successView" value="" />

            By adding "redirect" it will work...

            u can also try this other way in your Controller class

            return new ModelAndView(new RedirectView(""));

            Note : But u should use either one only, not using the "redirect:" in xml and new RedirectView() in controller at same time.


            • #7

              Were you able to send a model to the RedirectView?



              • #8
                Its not possible....since u r implementing new RedirectView...


                • #9
                  u cannot access the model object from one controller to another controller since u r used redirectView