1. 程式人生 > >spring mvc 伺服器端輸出一條可執行js

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