Results 1 to 5 of 5

Thread: Redirect issue

  1. #1

    Default 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.
    Neeraj Kumar

  2. #2
    Join Date
    Oct 2004
    Location
    Herndon, VA, US
    Posts
    648

    Default

    IIRC, only UrlBasedViewResolver and its subclasses support the "redirect:" notion. Which view resolver are you using?
    --Jing Xue

  3. #3

    Default

    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>
    Neeraj Kumar

  4. #4
    Join Date
    Aug 2004
    Location
    Atlanta, GA
    Posts
    129

    Default

    Quote 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
    Randy

  5. #5

    Default

    That worked. Thanks guys.
    Neeraj Kumar

Similar Threads

  1. [cas] why I redirect to https
    By iamteri in forum Security
    Replies: 2
    Last Post: Sep 4th, 2007, 09:35 AM
  2. Workaround for BeanUtils Issue in Spring??
    By tdanecito in forum Container
    Replies: 4
    Last Post: Apr 5th, 2006, 02:26 PM
  3. Redirect expose jsp path?
    By jackysee in forum Web
    Replies: 2
    Last Post: Jun 28th, 2005, 10:01 PM
  4. redirect: prefix and view resolver
    By sjivan in forum Web
    Replies: 2
    Last Post: Dec 20th, 2004, 03:28 PM
  5. Replies: 3
    Last Post: Dec 8th, 2004, 10:23 AM

Posting Permissions

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