2

How can i open the URL in new window or tab when written the code in spring controller class. Below is the code:

@RequestMapping(value = "/showPage", method = RequestMethod.GET)
  public ModelAndView openDataLink(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception {  

    //logic to get or construct the URL 
    return new ModelAndView(new RedirectView("http://www.google.com"));  
  }  

From my application when i access the contoller, google.com is getting opened in the same window from where i'am accessing the application. How can i make google.com open in new window or tab when accessing controller form my application. Please suggest.

user4103233
  • 47
  • 1
  • 1
  • 9
  • Relevant: http://forum.spring.io/forum/spring-projects/web/49351-redirectview-can-i-have-this-redirect-to-a-new-window – Brian Oct 16 '14 at 20:01

2 Answers2

1

Opening a new window will have to be done by the browser via html (<a target="blank_">) or javascript. Java and/or Spring have nothing to do with this.

zmf
  • 9,095
  • 2
  • 26
  • 28
  • This. Also, you can set the `target` attribute to any string, and then all links with the same `target` attribute will open in the same external window. – Raphael Serota Oct 16 '14 at 21:13
0

Refer to this solution if you want to achieve this from the jsp where you are submitting form to the controller:

How to open new tab of same browser while submit jsp form

Community
  • 1
  • 1
user2254601
  • 164
  • 2
  • 8