Results 1 to 9 of 9

Thread: How do I redirect from setSuccessView() to a Controller

  1. #1
    Join Date
    May 2007
    Posts
    3

    Default 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: "/sessionStatsStaticUsersList.do".

    Code:
        <!-- ========================= 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>
        </bean>
            
    	<!-- ========================= DEFINITIONS OF PUBLIC CONTROLLERS ========================= -->
    
    	<bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    
    	<bean name="/home.do" class="web.controller.HomeController">
    	</bean>
    	
    	<bean name="/sessionStatsStaticUsersList.do" class="web.controller.SessionStatsStaticController">
    		<property name="incomingPage" value="allUsersList"/>
    		<property name="server" value="Local"/>
    	</bean>
    Thanks and regards,
    Last edited by bogdanb; May 10th, 2007 at 01:42 AM.

  2. #2

    Default 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="/sessionStatsStaticUsersList.do"/>
    This successview is nothing but setSuccessView().
    It will redirect to another controller as u defined in xml..........


    Regards,
    Murugan.C

  3. #3
    Join Date
    May 2007
    Posts
    3

    Default

    Hi,

    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. #4

    Default

    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. #5
    Join Date
    Feb 2008
    Location
    Esporles, Mallorca, Spain
    Posts
    7

    Default

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

    <property name="successView" value="redirect:sessionStatsStaticUsersList.do" />

  6. #6

    Default Re : successView

    <property name="successView" value="redirect:sessionStatsStaticUsersList.do" />

    By adding "redirect" it will work...

    u can also try this other way in your Controller class

    return new ModelAndView(new RedirectView("sessionStatsStaticUsersList.do"));

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

  7. #7
    Join Date
    Jan 2008
    Posts
    25

    Default

    Hi,

    Were you able to send a model to the RedirectView?

    Anu

  8. #8

    Default

    Its not possible....since u r implementing new RedirectView...

  9. #9

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •