我想从url:
填充text属性<span th:text="@{/admin/user/getUserName}"></span>
RestController:
@RequestMapping(value = "/admin/user/getUserName")
public String getUserName(){
return "Hello From Controller";
}
我希望属性文本设置为&#34; Hello From Controller&#34;但设置的值是&#34; / admin / user / getUserName&#34;。有人可以帮助我吗?
答案 0 :(得分:0)
您可以这样实现目标(使用jquery):
在控制器中:
@RequestMapping(value = "/admin/user/getUserName")
@ResponseBody
public String getUserName(){
return "Hello From Controller";
}
视图中:
<span id="tt"></span>
<script>
$(function () {
$("#tt").load("/admin/user/getUserName");
});
</script>