当然,它已经不起作用了。这是:
@{/api/users/{user}/menus/vegan/datatableList(user=${#authentication.principal.id})}
@{ajaxUrl}
href="ajaxUrl"
.你可以更接近
@{${ajaxUrl}}
// Controller
model.addAttribute("ajaxUrl", "/api/users/{user}/menus/vegan/datatableList");
// JavaScript
var ajaxUrl = /*[[@{${ajaxUrl}(user=${#authentication.principal.id})}]]*/ "";
如果要传递整个URL,则必须自己计算用户ID。例如:
// Controller
String user = "1"; // You need to supply the user id here. (However you get that in java.)
model.addAttribute("ajaxUrl", "/api/users/" + user + "/menus/vegan/datatableList");
// JavaScript
var ajaxUrl = /*[[@{${ajaxUrl}}]]*/ "";