@thatmaniscool

Как передать булевый массив в spring-boot & thymeleaf?

Имеется класс, который содержит в себе полезную "нагрузку".
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Info {
//	Works fine!
	private String [] strArr;
//	Works fine!
	private boolean status1;
//	Not work at all!
	private boolean [] arr;
}


B имеется класс контроллер:
@Controller
@RequestMapping("/")
public class MyController {
	
	@GetMapping
	public String getIndex (Model model) {
		model.addAttribute("info", new Info());
		return "index";
	}
	
	@PostMapping
	public String postIndex (@ModelAttribute Info tags) {
		return "redirect:/";
	}
}


И просто html шаблон:
<body>
    <form th:action="@{/}" method="POST" th:object="${info}">
      <!-- The arr of text's inputs work so fine! -->
      <input type="text" name="" id="" th:field="*{strArr[0]}" /><br />
      <input type="text" name="" id="" th:field="*{strArr[1]}" /><br />
      <input type="text" name="" id="" th:field="*{strArr[2]}" /><br />
      <!-- The single checkbox works fine! -->
      <input type="checkbox" name="" id="" th:field="*{status}" /><br />
      <!-- Fails when I'm trying to use the boolean arr. -->
      <input type="checkbox" name="" id="" th:field="*{arr[0]}" />
      <input type="checkbox" name="" id="" th:field="*{arr[1]}" />
      <input type="checkbox" name="" id="" th:field="*{arr[2]}" />
    </form>
  </body>


Собственно при попытке использовать булевый массив, страничка падает. Что я делаю не так?
  • Вопрос задан
  • 52 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы