1. 程式人生 > >Spring:url 標籤賦值給js變數

Spring:url 標籤賦值給js變數

$("#deleteSingleUser").click(function (e) {
                e.preventDefault();
                var id = $("#userId").val();
                <spring:url value="/robbie/deleteSingleUser/" htmlEscape="true" javaScriptEscape="true" var="urltemp"/>;
                var deleteUrl = "${urltemp}";
                var url = deleteUrl + id;
                alert(url);
                $.get(url,function (data) {
                    $("#searchResults").text(data);
                })
                return false;
            });

 var deleteUrl = "${urltemp}";

這行一定要加引號!