Javascript 如何将Thymeleaf对象从基本页面传递到ajax生成的页面?
我有一个注册过程,有子步骤,我有这些子步骤的单独HTML页面,以便于管理。现在我有了一个“基本页面”,即容器。下面的div是我加载子页面的地方Javascript 如何将Thymeleaf对象从基本页面传递到ajax生成的页面?,javascript,jquery,spring-boot,thymeleaf,Javascript,Jquery,Spring Boot,Thymeleaf,我有一个注册过程,有子步骤,我有这些子步骤的单独HTML页面,以便于管理。现在我有了一个“基本页面”,即容器。下面的div是我加载子页面的地方 <div id="substeps" th:object="${stepFourForm}"> </div> 加载的子步骤页面如何检索基本页面上的stepFourForm对象?在加载子步骤页面之前,您应该删除div内容。你可以用胸腺细胞碎片来做 $.ajax({ type: "GET", url: "/examp
<div id="substeps" th:object="${stepFourForm}">
</div>
加载的子步骤页面如何检索基本页面上的
stepFourForm
对象?在加载子步骤页面之前,您应该删除div
内容。你可以用胸腺细胞碎片来做
$.ajax({
type: "GET",
url: "/example-url",
success: function (data) {
$('#substeps').html('');
$('#substeps').html(data);
}
});
控制器代码:
@RequestMapping("/example-url")
public ModelAndView example() {
ModelAndView view = new ModelAndView("substep1 :: content");
return view;
}
示例片段html名称子步骤1:
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:dt="http://www.thymeleaf.org/dandelion/datatables">
<head>
<meta charset="UTF-8"/>
<title>Title</title>
</head>
<body>
<div th:fragment="content">
--some content
</div>
</body>
</html>
标题
--一些内容
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:dt="http://www.thymeleaf.org/dandelion/datatables">
<head>
<meta charset="UTF-8"/>
<title>Title</title>
</head>
<body>
<div th:fragment="content">
--some content
</div>
</body>
</html>