js获取后台model变量的内容

@RequestMapping("/refresh")
public class IndexController {

    @RequestMapping
    public String globalRefresh(Model model) {
        Integer h=2;
        model.addAttribute("uu",h);
        return "test";
    }
}

这是controller里传入变量

<script>
    var t=[[${uu}]];//这里就取到了model变量的值

    function localRefresh() {

        $('#test').load("/local/"+t);
    }
</script>

一共就一句话

var t=[[${后台变量名}]];

猜你喜欢

转载自blog.csdn.net/ouyang_ouba/article/details/90735158