SpringBoot中HttpServletResponse重定向到内部html页面

分类:计算机 | Spring | SpringBoot | 综合 1472
更新:2020-04-12 17:03:32
编辑

SpringBoot工程resources/static中有个xxx.html页面,通过下面代码可以重定向到该页面:

HttpServletResponse response = (HttpServletResponse) servletResponse; //响应
response.sendRedirect("xxx.html");

假如项目部署的地址是:http://ip:port/appname,那么重定向的页面地址就是:http://ip:port/appname/xxx.html