@RequestMapping(value = "/test",produces = "text/html; charset=UTF-8")
@ResponseBody
public String test(){
String url = "";
return "<script>window.location.href = '"+url+"';</script>";
注意点 1:@ResponseBody注意 2:produces = “text/html;charset=utf-8” 3:返回值为String,即为执行的js 标签:String,produces,spring,charset,html,js,mvc From: https://www.cnblogs.com/whm-blog/p/17631236.html