How can i open the URL in new window or tab when written the code in spring controller class. Below is the code:
在Spring控制器类中编写代码时,如何在新窗口或选项卡中打开URL。以下是代码:
@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.
从我的应用程序访问控制器时,google.com将在我访问应用程序的同一窗口中打开。当我从我的应用程序访问控制器时,如何在新窗口或选项卡中打开google.com。请建议。
2 个解决方案
#1
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.
打开一个新窗口必须由浏览器通过html()或javascript完成。 Java和/或Spring与此无关。
#2
0
Refer to this solution if you want to achieve this from the jsp where you are submitting form to the controller:
如果要从提交表单的jsp到控制器实现此目的,请参阅此解决方案:
How to open new tab of same browser while submit jsp form
如何在提交jsp表单时打开同一浏览器的新选项卡
#1
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.
打开一个新窗口必须由浏览器通过html()或javascript完成。 Java和/或Spring与此无关。
#2
0
Refer to this solution if you want to achieve this from the jsp where you are submitting form to the controller:
如果要从提交表单的jsp到控制器实现此目的,请参阅此解决方案:
How to open new tab of same browser while submit jsp form
如何在提交jsp表单时打开同一浏览器的新选项卡