【发布时间】:2019-11-29 05:25:51
【问题描述】:
我的 index.html
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
(js and css)
</head>
<body>
<div>
<button name="sendPaperByMessage" th:if="${paper.issend} ne 'sended'" th:paperId="${paper.paperid}">sendMessage</button>
</div>
<script th:inline="javascript">
$("button[name='sendPaperByMessage']").click(function () {
var paperId = $(this).attr("paperId");
$.ajax({
url: "/api/sendMessage",
type: "post",
data: {"paperId": paperId},
success: function (data) {
console.log("success");
}
})
});
</script>
</body>
</html>
和我的控制器:
@PostMapping("/api/sendMessage")
public Object sendMessage(@RequestParam("paperId") String paperId){
// paperService.sendMessage(paperId);
Map map = new HashMap();
map.put("Message", "success");
return map;
}
我省略了一些代码并做了一个演示。 响应是错误解析模板 [api/sendMessage],模板可能不存在或可能无法被任何已配置的模板解析器访问”
【问题讨论】:
-
检查this 可能对你有帮助。
标签: ajax spring-boot thymeleaf