java 输出js实现地址跳转

简介:

        有时候需要重定向到别的项目去,又不想更改前端,可以试试这个方法

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@PostMapping("/redirectUrl")
public void redirectUrl(HttpServletRequest request, HttpServletResponse response) throws IOException {

	String redirectUrl = "www.baidu.com";
	response.setHeader("Content-Type", "text/html; charset=UTF-8");
	response.getWriter().write("<script>window.location.replace(\'" + redirectUrl + "\')</script>");
	response.getWriter().flush();
	response.getWriter().close();
}

上一篇:4 — jsr303检验


下一篇:business logic on Power App with Modern driven