Announcement Announcement Module
Collapse
No announcement yet.
Redirect issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Redirect issue

    Code:
    	<bean id="urlMapping"
    		class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<props>
    				<prop key="/admin/admin_home.html">
    					AdminController
    				</prop>
    			</props>
    		</property>
    	</bean>
    Adding a user controller

    Code:
    	<bean id="AdminAddUserController"
    		class="com.fanniemae.disclosure.pcrf.webapp.action.AdminAddUserController">
    		<property name="formView">
    			<value>admin_addUser</value>
    		</property>
    		<property name="successView">
    			<value>redirect&#58;admin/admin_home.html</value>
    		</property>
    	</bean>
    The above mentioned code for redirect doesn't work. I guess it's because there are forward slashes in the redirect parameter. I was able to solve the problem by following code in the controller:
    Code:
    		RedirectView redirectView = new RedirectView&#40;"/admin/admin_home.html",true&#41;;
    		return new ModelAndView&#40;redirectView&#41;;
    Although the problem was solved, I would prefer a solution where the view name is not hard coded in the java file.

    Any idea on how I could achieve the redirect with the configuration in xml and not in java.

  • #2
    IIRC, only UrlBasedViewResolver and its subclasses support the "redirect:" notion. Which view resolver are you using?

    Comment


    • #3
      I did not know about the constraint. I am using ResourceBundleViewResolver.

      Code:
      	<bean id="viewResolver"
      		class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
      		<property name="basename">
      			<value>views</value>
      		</property>
      	</bean>

      Comment


      • #4
        Originally posted by neeraj_cmu
        I am using ResourceBundleViewResolver.
        In that case, make your view class a RedirectView.
        Code:
        adminHomeRedirect.class=org.springframework.web.servlet.view.RedirectView
        adminHomeRedirect.url=admin/admin_home.html

        Comment


        • #5
          That worked. Thanks guys.

          Comment

          Working...
          X