質問編集履歴
17
タイトル修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
プルダウンの中身だけを更新したい
|
1
|
+
[Spring Boot+thymleaf] プルダウンの中身だけを更新したい
|
body
CHANGED
File without changes
|
16
追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -130,7 +130,7 @@
|
|
130
130
|
|
131
131
|
### 試したこと2
|
132
132
|
$('#tdid').html(data); を、
|
133
|
-
$('#tdid').html('<div th:replace="replace :: flgmntB"'); と、
|
133
|
+
$('#tdid').html('<div th:replace="replace :: flgmntB"></div>'); と、
|
134
134
|
直接タグを送り込むなどもしましたが、何も表示されない(replace :: flgmntBが働かないのでdivがカラ)だけでした。とにかくThymeleafがどこにもいない。という感じです。
|
135
135
|
|
136
136
|
### 補足情報(FW/ツールのバージョンなど)
|
15
追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -128,6 +128,11 @@
|
|
128
128
|
jsの$('#tdid').html(data);の実行結果は
|
129
129
|
<td id="tdid">index :: flgmntA</td>となり、contorollerから送った文字列が画面に表示されるばかりです。
|
130
130
|
|
131
|
+
### 試したこと2
|
132
|
+
$('#tdid').html(data); を、
|
133
|
+
$('#tdid').html('<div th:replace="replace :: flgmntB"'); と、
|
134
|
+
直接タグを送り込むなどもしましたが、何も表示されない(replace :: flgmntBが働かないのでdivがカラ)だけでした。とにかくThymeleafがどこにもいない。という感じです。
|
135
|
+
|
131
136
|
### 補足情報(FW/ツールのバージョンなど)
|
132
137
|
thymeleaf 3.0.11.RELEASE
|
133
138
|
(環境構築した者が現場にはすでに居らず、thymeleafを初めて触る者しか居りません…)
|
14
文章を修正してみました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -130,4 +130,11 @@
|
|
130
130
|
|
131
131
|
### 補足情報(FW/ツールのバージョンなど)
|
132
132
|
thymeleaf 3.0.11.RELEASE
|
133
|
-
(環境構築した者が現場にはすでに居らず、thymeleafを初めて触る者しか居りません…)
|
133
|
+
(環境構築した者が現場にはすでに居らず、thymeleafを初めて触る者しか居りません…)
|
134
|
+
|
135
|
+
コードの書き方の問題というよりは、表示後の画面においてthymeleafが有効にならないことが問題なのでは、と、現時点では思っております。そのため、
|
136
|
+
https://teratail.com/questions/220606
|
137
|
+
https://teratail.com/questions/220621
|
138
|
+
といった質問もさせていただいております。
|
139
|
+
|
140
|
+
あわせてよろしくお願いいたします。
|
13
追加、削除してみました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,34 +4,24 @@
|
|
4
4
|
|
5
5
|
### 発生している問題・エラーメッセージ
|
6
6
|
|
7
|
-
htmlには
|
8
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
9
|
-
|
7
|
+
期待値は、thymeleafのテンプレートフラグメントという機能によって、指定した場所にプルダウンが再構築されることですが、
|
10
|
-
|
8
|
+
実際は、(おそらく)thymeleafを通らずhtmlで処理されてしまっており、"index :: flgmntA"という指定がそのまま文字列として画面に表示されてしまう。
|
11
|
-
と記述しているのですが、表示された画面のソースを見ると
|
12
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
|
-
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
14
|
-
と、thymeleaf.orgが消えてしまっています。
|
15
|
-
それが原因かはわかりませんが。
|
16
9
|
|
17
|
-
期待値は、thymeleafのテンプレートフラグメントという機能によって、指定した場所にプルダウンが構築されることですが、
|
18
|
-
実際は、(おそらく)thymeleafを通らずhtmlで処理されてしまい、"index :: flgmntA"という指定がそのまま文字列として処理されてしまう。
|
19
|
-
|
20
|
-
【index.html】
|
10
|
+
【index.html】(メイン画面)
|
21
11
|
```html
|
22
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
23
13
|
xmlns:th="http://www.thymeleaf.org"
|
24
14
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
25
15
|
<head></head>
|
26
16
|
<body>
|
27
|
-
<input type="text" id="ss1" />
|
17
|
+
<input type="text" id="ss1" /> <!--☆検索条件☆-->
|
28
|
-
<input type="text" id="ss2" />
|
18
|
+
<input type="text" id="ss2" /> <!--☆検索条件☆-->
|
29
|
-
<input type="text" id="ss3" />
|
19
|
+
<input type="text" id="ss3" /> <!--☆検索条件☆-->
|
30
20
|
<table>
|
31
21
|
<tr>
|
32
22
|
<td><div>選択肢</div></td>
|
33
23
|
<td id="tdid">
|
34
|
-
<div th:replace="replace :: flgmntB"></div>
|
24
|
+
<div th:replace="replace :: flgmntB" th:fragment="flgmntA"></div> <!--★ここに置き換わる★-->
|
35
25
|
</td>
|
36
26
|
</tr>
|
37
27
|
</table>
|
@@ -47,7 +37,7 @@
|
|
47
37
|
<title></title>
|
48
38
|
</head>
|
49
39
|
<body>
|
50
|
-
<select id="id1" name="id1" th:fragment="flgmntB">
|
40
|
+
<select id="id1" name="id1" th:fragment="flgmntB"> <!--★これが置き換わる★-->
|
51
41
|
<option value="">------------------------------------</option>
|
52
42
|
<option th:each="item : ${selectLst}"
|
53
43
|
th:value="${item.value}"
|
@@ -60,8 +50,6 @@
|
|
60
50
|
【js】
|
61
51
|
```JavaScript
|
62
52
|
$('input').change(function() {
|
63
|
-
$('#tdid').html('<div th:replace="replace :: flgmntB" th:fragment="flgmntA"></div>');
|
64
|
-
|
65
53
|
event.preventDefault();
|
66
54
|
var dataWhere = {
|
67
55
|
"s1" : $("#ss1").val(),
|
@@ -75,7 +63,7 @@
|
|
75
63
|
data : JSON.stringify(dataWhere),
|
76
64
|
contentType : 'application/json',
|
77
65
|
success : function(data, status, xhr) {
|
78
|
-
$('#tdid').html(data);
|
66
|
+
$('#tdid').html(data); // ★data="index :: flgmntA"
|
79
67
|
},
|
80
68
|
error : function(XMLHttpRequest, textStatus, errorThrown) {
|
81
69
|
(略)
|
@@ -98,7 +86,7 @@
|
|
98
86
|
map.put("key3", "value3");
|
99
87
|
|
100
88
|
mav.setViewName("index");
|
101
|
-
mav.addObject("selectLst", map);
|
89
|
+
mav.addObject("selectLst", map); // ★プルダウンの中身★
|
102
90
|
return mav;
|
103
91
|
}
|
104
92
|
|
@@ -115,8 +103,8 @@
|
|
115
103
|
map.put("key1", "value1");
|
116
104
|
map.put("key2", "value2");
|
117
105
|
|
118
|
-
model.addAttribute("selectLst", map);
|
106
|
+
model.addAttribute("selectLst", map); // ★プルダウンの中身★
|
119
|
-
return "index :: flgmntA";
|
107
|
+
return "index :: flgmntA"; // ★置換指示★
|
120
108
|
|
121
109
|
} catch (Exception e) {
|
122
110
|
e.printStackTrace();
|
@@ -128,6 +116,7 @@
|
|
128
116
|
|
129
117
|
※こちらのサイトを参考にさせていただきました。
|
130
118
|
[Spring(Java) + Thymeleaf でページの一部更新(Ajax)](https://qiita.com/yoyoyo/items/b288f067d5de04f26046)
|
119
|
+
(類似のサイトも複数参考にさせていただきました)
|
131
120
|
|
132
121
|
初期表示はうまくいっており、初期表示用に送り出したListの内容がプルダウンになって
|
133
122
|
index.htmlの<div th:replace="replace :: flgmntB"></div>
|
@@ -137,7 +126,7 @@
|
|
137
126
|
それらによる検索結果がModelMapにセットされているところまでは確認できています。
|
138
127
|
ですが、
|
139
128
|
jsの$('#tdid').html(data);の実行結果は
|
140
|
-
<td id="tdid">index :: flgmntA</td>と、contorollerから送った文字列が画面に表示されるばかりです。
|
129
|
+
<td id="tdid">index :: flgmntA</td>となり、contorollerから送った文字列が画面に表示されるばかりです。
|
141
130
|
|
142
131
|
### 補足情報(FW/ツールのバージョンなど)
|
143
132
|
thymeleaf 3.0.11.RELEASE
|
12
タグ追加
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
11
文章を修正してみました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -4,9 +4,19 @@
|
|
4
4
|
|
5
5
|
### 発生している問題・エラーメッセージ
|
6
6
|
|
7
|
-
htmlには
|
7
|
+
htmlには
|
8
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
9
|
+
xmlns:th="http://www.thymeleaf.org"
|
10
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
11
|
+
と記述しているのですが、表示された画面のソースを見ると
|
12
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
14
|
+
と、thymeleaf.orgが消えてしまっています。
|
8
15
|
それが原因かはわかりませんが。
|
9
16
|
|
17
|
+
期待値は、thymeleafのテンプレートフラグメントという機能によって、指定した場所にプルダウンが構築されることですが、
|
18
|
+
実際は、(おそらく)thymeleafを通らずhtmlで処理されてしまい、"index :: flgmntA"という指定がそのまま文字列として処理されてしまう。
|
19
|
+
|
10
20
|
【index.html】
|
11
21
|
```html
|
12
22
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
@@ -119,9 +129,15 @@
|
|
119
129
|
※こちらのサイトを参考にさせていただきました。
|
120
130
|
[Spring(Java) + Thymeleaf でページの一部更新(Ajax)](https://qiita.com/yoyoyo/items/b288f067d5de04f26046)
|
121
131
|
|
132
|
+
初期表示はうまくいっており、初期表示用に送り出したListの内容がプルダウンになって
|
122
|
-
|
133
|
+
index.htmlの<div th:replace="replace :: flgmntB"></div>
|
134
|
+
の箇所に表示されています。
|
135
|
+
また、
|
123
|
-
|
136
|
+
index.htmlの<input type="text" id="ss1" />などに入力した値はcontorollerに送られ、
|
137
|
+
それらによる検索結果がModelMapにセットされているところまでは確認できています。
|
138
|
+
ですが、
|
139
|
+
jsの$('#tdid').html(data);の実行結果は
|
124
|
-
|
140
|
+
<td id="tdid">index :: flgmntA</td>と、contorollerから送った文字列が画面に表示されるばかりです。
|
125
141
|
|
126
142
|
### 補足情報(FW/ツールのバージョンなど)
|
127
143
|
thymeleaf 3.0.11.RELEASE
|
10
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,8 +7,8 @@
|
|
7
7
|
htmlには<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と記述しているのですが、表示された画面のソースを見ると<html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と、thymeleaf.orgが消えてしまっています。
|
8
8
|
それが原因かはわかりませんが。
|
9
9
|
|
10
|
+
【index.html】
|
10
11
|
```html
|
11
|
-
【index.html】
|
12
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
13
|
xmlns:th="http://www.thymeleaf.org"
|
14
14
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
@@ -28,8 +28,8 @@
|
|
28
28
|
</body>
|
29
29
|
</html>
|
30
30
|
```
|
31
|
+
【replace.html】
|
31
32
|
```html
|
32
|
-
【replace.html】
|
33
33
|
<!DOCTYPE html>
|
34
34
|
<html xmlns:th="http://www.thymeleaf.org">
|
35
35
|
<head>
|
@@ -47,6 +47,7 @@
|
|
47
47
|
</body>
|
48
48
|
</html>
|
49
49
|
```
|
50
|
+
【js】
|
50
51
|
```JavaScript
|
51
52
|
$('input').change(function() {
|
52
53
|
$('#tdid').html('<div th:replace="replace :: flgmntB" th:fragment="flgmntA"></div>');
|
@@ -72,8 +73,8 @@
|
|
72
73
|
});
|
73
74
|
});
|
74
75
|
```
|
76
|
+
【Controller】
|
75
77
|
```java
|
76
|
-
【Controller】
|
77
78
|
@RestController
|
78
79
|
public class TLController {
|
79
80
|
|
9
コピペで使えるかは難しいですが、いくらか増量しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,20 +10,23 @@
|
|
10
10
|
```html
|
11
11
|
【index.html】
|
12
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
|
-
xmlns:th="http://www.thymeleaf.org"
|
13
|
+
xmlns:th="http://www.thymeleaf.org"
|
14
|
-
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
14
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
15
|
+
<head></head>
|
15
|
-
|
16
|
+
<body>
|
16
|
-
<input type="text" id="ss1" />
|
17
|
+
<input type="text" id="ss1" />
|
17
|
-
<input type="text" id="ss2" />
|
18
|
+
<input type="text" id="ss2" />
|
18
|
-
<input type="text" id="ss3" />
|
19
|
+
<input type="text" id="ss3" />
|
19
|
-
<table>
|
20
|
+
<table>
|
20
21
|
<tr>
|
21
|
-
|
22
|
+
<td><div>選択肢</div></td>
|
22
|
-
|
23
|
+
<td id="tdid">
|
23
|
-
|
24
|
+
<div th:replace="replace :: flgmntB"></div>
|
24
|
-
|
25
|
+
</td>
|
25
26
|
</tr>
|
26
|
-
</table>
|
27
|
+
</table>
|
28
|
+
</body>
|
29
|
+
</html>
|
27
30
|
```
|
28
31
|
```html
|
29
32
|
【replace.html】
|
@@ -62,7 +65,6 @@
|
|
62
65
|
contentType : 'application/json',
|
63
66
|
success : function(data, status, xhr) {
|
64
67
|
$('#tdid').html(data);
|
65
|
-
(略)
|
66
68
|
},
|
67
69
|
error : function(XMLHttpRequest, textStatus, errorThrown) {
|
68
70
|
(略)
|
@@ -72,19 +74,43 @@
|
|
72
74
|
```
|
73
75
|
```java
|
74
76
|
【Controller】
|
75
|
-
@
|
77
|
+
@RestController
|
76
|
-
public
|
78
|
+
public class TLController {
|
77
79
|
|
80
|
+
// 初期表示
|
81
|
+
@RequestMapping(value = "/", method = RequestMethod.GET)
|
78
|
-
|
82
|
+
public ModelAndView index(ModelAndView mav) {
|
79
|
-
|
83
|
+
// 初期表示のMap
|
80
|
-
|
84
|
+
Map<String, String> map = new LinkedHashMap<String, String>();
|
81
|
-
});
|
82
|
-
|
85
|
+
map.put("key1", "value1");
|
83
|
-
|
86
|
+
map.put("key2", "value2");
|
87
|
+
map.put("key3", "value3");
|
84
88
|
|
89
|
+
mav.setViewName("index");
|
90
|
+
mav.addObject("selectLst", map);
|
91
|
+
return mav;
|
92
|
+
}
|
93
|
+
|
94
|
+
// 絞り込み検索
|
95
|
+
@RequestMapping(value = "contrMthd", consumes = MediaType.APPLICATION_JSON_VALUE)
|
96
|
+
public String pulldown(@RequestBody String data, ModelMap model) {
|
97
|
+
|
98
|
+
ObjectMapper mapper = new ObjectMapper();
|
99
|
+
try {
|
100
|
+
Map<String, String> whr = mapper.readValue(data, new TypeReference<HashMap<String, String>>() {
|
101
|
+
});
|
102
|
+
// whrで検索したつもりのMap
|
103
|
+
Map<String, String> map = new LinkedHashMap<String, String>();
|
104
|
+
map.put("key1", "value1");
|
105
|
+
map.put("key2", "value2");
|
106
|
+
|
107
|
+
model.addAttribute("selectLst", map);
|
108
|
+
return "index :: flgmntA";
|
109
|
+
|
85
|
-
|
110
|
+
} catch (Exception e) {
|
86
|
-
|
111
|
+
e.printStackTrace();
|
87
|
-
|
112
|
+
}
|
113
|
+
}
|
88
114
|
}
|
89
115
|
```
|
90
116
|
### 試したこと
|
8
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -71,7 +71,7 @@
|
|
71
71
|
});
|
72
72
|
```
|
73
73
|
```java
|
74
|
-
Controller
|
74
|
+
【Controller】
|
75
75
|
@RequestMapping(value = "contrMthd", consumes = MediaType.APPLICATION_JSON_VALUE)
|
76
76
|
public String pulldown(@RequestBody String data, ModelMap model) {
|
77
77
|
|
7
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
それが原因かはわかりませんが。
|
9
9
|
|
10
10
|
```html
|
11
|
-
index.html
|
11
|
+
【index.html】
|
12
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
13
|
xmlns:th="http://www.thymeleaf.org"
|
14
14
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
@@ -25,8 +25,8 @@
|
|
25
25
|
</tr>
|
26
26
|
</table>
|
27
27
|
```
|
28
|
-
```
|
28
|
+
```html
|
29
|
-
replace.html
|
29
|
+
【replace.html】
|
30
30
|
<!DOCTYPE html>
|
31
31
|
<html xmlns:th="http://www.thymeleaf.org">
|
32
32
|
<head>
|
@@ -70,7 +70,7 @@
|
|
70
70
|
});
|
71
71
|
});
|
72
72
|
```
|
73
|
-
```
|
73
|
+
```java
|
74
74
|
Controller
|
75
75
|
@RequestMapping(value = "contrMthd", consumes = MediaType.APPLICATION_JSON_VALUE)
|
76
76
|
public String pulldown(@RequestBody String data, ModelMap model) {
|
6
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
htmlには<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と記述しているのですが、表示された画面のソースを見ると<html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と、thymeleaf.orgが消えてしまっています。
|
8
8
|
それが原因かはわかりませんが。
|
9
9
|
|
10
|
-
```
|
10
|
+
```html
|
11
11
|
index.html
|
12
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
13
|
xmlns:th="http://www.thymeleaf.org"
|
5
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -44,8 +44,7 @@
|
|
44
44
|
</body>
|
45
45
|
</html>
|
46
46
|
```
|
47
|
-
```
|
47
|
+
```JavaScript
|
48
|
-
js
|
49
48
|
$('input').change(function() {
|
50
49
|
$('#tdid').html('<div th:replace="replace :: flgmntB" th:fragment="flgmntA"></div>');
|
51
50
|
|
4
書式
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
3
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,8 @@
|
|
7
7
|
htmlには<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と記述しているのですが、表示された画面のソースを見ると<html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と、thymeleaf.orgが消えてしまっています。
|
8
8
|
それが原因かはわかりませんが。
|
9
9
|
|
10
|
+
```
|
10
|
-
|
11
|
+
index.html
|
11
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
12
13
|
xmlns:th="http://www.thymeleaf.org"
|
13
14
|
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
2
書式
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,10 +7,10 @@
|
|
7
7
|
htmlには<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と記述しているのですが、表示された画面のソースを見ると<html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と、thymeleaf.orgが消えてしまっています。
|
8
8
|
それが原因かはわかりませんが。
|
9
9
|
|
10
|
-
```
|
11
|
-
index.html
|
10
|
+
```index.html
|
12
|
-
<html xmlns="http://www.w3.org/1999/xhtml"
|
11
|
+
<html xmlns="http://www.w3.org/1999/xhtml"
|
13
|
-
xmlns:th="http://www.thymeleaf.org"
|
12
|
+
xmlns:th="http://www.thymeleaf.org"
|
13
|
+
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
|
14
14
|
(略)
|
15
15
|
<input type="text" id="ss1" />
|
16
16
|
<input type="text" id="ss2" />
|
1
書式変更中(いったん保存)
title
CHANGED
File without changes
|
body
CHANGED
@@ -7,7 +7,8 @@
|
|
7
7
|
htmlには<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と記述しているのですが、表示された画面のソースを見ると<html xmlns="http://www.w3.org/1999/xhtml" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"> と、thymeleaf.orgが消えてしまっています。
|
8
8
|
それが原因かはわかりませんが。
|
9
9
|
|
10
|
+
```
|
10
|
-
|
11
|
+
index.html
|
11
12
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
12
13
|
xmlns:th="http://www.thymeleaf.org">
|
13
14
|
(略)
|
@@ -22,8 +23,9 @@
|
|
22
23
|
</td>
|
23
24
|
</tr>
|
24
25
|
</table>
|
25
|
-
|
26
|
+
```
|
27
|
+
```
|
26
|
-
|
28
|
+
replace.html
|
27
29
|
<!DOCTYPE html>
|
28
30
|
<html xmlns:th="http://www.thymeleaf.org">
|
29
31
|
<head>
|
@@ -40,8 +42,9 @@
|
|
40
42
|
</select>
|
41
43
|
</body>
|
42
44
|
</html>
|
43
|
-
|
45
|
+
```
|
46
|
+
```
|
44
|
-
|
47
|
+
js
|
45
48
|
$('input').change(function() {
|
46
49
|
$('#tdid').html('<div th:replace="replace :: flgmntB" th:fragment="flgmntA"></div>');
|
47
50
|
|
@@ -66,8 +69,9 @@
|
|
66
69
|
}
|
67
70
|
});
|
68
71
|
});
|
69
|
-
|
72
|
+
```
|
73
|
+
```
|
70
|
-
|
74
|
+
Controller
|
71
75
|
@RequestMapping(value = "contrMthd", consumes = MediaType.APPLICATION_JSON_VALUE)
|
72
76
|
public String pulldown(@RequestBody String data, ModelMap model) {
|
73
77
|
|
@@ -82,11 +86,11 @@
|
|
82
86
|
(略)
|
83
87
|
}
|
84
88
|
}
|
85
|
-
|
89
|
+
```
|
86
90
|
### 試したこと
|
87
91
|
|
88
92
|
※こちらのサイトを参考にさせていただきました。
|
89
|
-
https://qiita.com/yoyoyo/items/b288f067d5de04f26046
|
93
|
+
[Spring(Java) + Thymeleaf でページの一部更新(Ajax)](https://qiita.com/yoyoyo/items/b288f067d5de04f26046)
|
90
94
|
|
91
95
|
初期表示はうまくいっており、初期表示用に送り出したListの内容がプルダウンになってindex.htmlの<div th:replace="replace :: flgmntB"></div>の箇所に表示されています。
|
92
96
|
また、index.htmlの<input type="text" id="ss1" />などに入力した値はcontorollerに送られ、それによる検索結果がModelMapにセットされているところまでは確認できています。
|