Results 1 to 3 of 3

Thread: Spring 3.0 forward to another Page without using HttpServletRequest

  1. #1

    Default Spring 3.0 forward to another Page without using HttpServletRequest

    My code to forward request to another page in Spring MVC looks like below:

    Code:
    	@RequestMapping(method = RequestMethod.POST)
    	public String handle(HttpServletRequest request,
    			HttpServletResponse response,
    			@RequestParam("myDesignFile") String myDesignFile)
    			throws Exception {
    
                   final String url = String.format("/frameset?__format=html&__report=report/%s", myDesignFile);		                        
    
                   request.getRequestDispatcher(url).forward(request, response);
    	
                   return null;
    	}
    how can i remove dependency on HttpServletRequest and HttpServletResponse in above code to make it more unit testable?

    is there any code like below in Spring that will not require request or response dependencies:

    Code:
    return "forward:" + url;

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    What you wrote should work... forward: and redirect: prefixes are supported by spring (this is mentioned in the reference guide).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2012
    Posts
    9

    Default

    Can you explain in bit more detail?

Posting Permissions

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