admin管理员组文章数量:1389761
I've been trying to assemble a data table display in html via thymeleaf.
In general, it's a part of a system meant to display, edit and create not preset sql database via browser I am working on at my spare time. I want it to be able to take in any form of database and generate sql queries based on the opions selected via buttons, or direct sql input. However, I faced a small problem with html output and I've been stuck at it for about 2 weeks by now.
Everything goes inside as expected, however, when I request the said table back, it returns nothing (my input/output is nullproof so technically it's null). Any ideas on what's wrong?
Here's the HTML
<!DOCTYPE html>
<html lang="en" xmlns:th=";>
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<form method="post">
<table>
<tr>
<td>
<button type="submit" name="send">UpdateDB</button>
</td>
</tr>
</table>
</form>
<form method="post" th:object="${arrayList}">
<table>
<tr>
<td th:each="currentType : ${currentTypesList}">
<select >
<option th:each="t : ${typeList}"
th:selected="${t.dataType==currentType}"
th:text="${t.dataTypeDesc}">
</option>
</select>
</td>
</tr>
<tr th:each="l : ${arrayList.tableData}">
<td th:each="s : ${l.tableRowData}">
<input th:value="*{tableData[__${arrayList.tableData.indexOf(l)}__]
.tableRowData[__${l.tableRowData.indexOf(s)}__]}" type="text">
</td>
</tr>
</table>
</form>
</body>
</html>
And controller (I removed unrelated to the above html parts)
@Controller
public class DataBaseController {
private final DataBaseService dataBaseService;
private String currentDBTitle;
@Autowired
public DataBaseController (DataBaseService dataBaseService) {
this.dataBaseService = dataBaseService;
}
@GetMapping("/DBView")
public String showDB(Model model) {
if (currentDBTitle != null) {
model.addAttribute("typeList", dataBaseService.getDataTypes());
model.addAttribute("currentTypesList", dataBaseService.getJDBCDataTypes(currentDBTitle));
model.addAttribute("arrayList", dataBaseService.getDataBase(currentDBTitle));
}
else {
return "redirect:/DBList";
}
return "DBView";
}
@PostMapping("/DBView")
public String selectDB(Model model, @RequestParam(value = "send") String action,
@ModelAttribute("arrayList") Table newData) {
if (currentDBTitle != null) {
model.addAttribute("typeList", dataBaseService.getDataTypes());
model.addAttribute("currentTypesList", dataBaseService.getJDBCDataTypes(currentDBTitle));
model.addAttribute("arrayList", dataBaseService.getDataBase(currentDBTitle));
dataBaseService.updateDB(currentDBTitle, newData);
return "/DBView";
}
else {
return "redirect:/DBList";
}
}
}
本文标签: spring bootThymeleaf input does not return List valuesStack Overflow
版权声明:本文标题:spring boot - Thymeleaf input does not return List values - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744565803a2613038.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论