spring mvc 前端返回 js

@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

posted on 2023-08-15 14:33  正义的伙伴!  阅读(33)  评论(0编辑  收藏  举报

导航

//增加一段JS脚本,为目录生成使用