Announcement Announcement Module
Collapse
No announcement yet.
Spring 3.0 forward to another Page without using HttpServletRequest Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    What you wrote should work... forward: and redirect: prefixes are supported by spring (this is mentioned in the reference guide).

    Comment


    • #3
      Can you explain in bit more detail?

      Comment

      Working...
      X