При нажатии «Сохранить» все поля вставляются в MySQL, кроме «Содержимое».
Когда поле отладки "Содержимое" пусто
Помогите, спасибо
Это мой код:
form-post.html
<form action="#" th:action="@{/savepost}" th:object="${post}"
method="POST" novalidate="novalidate">
<!-- <input type="hidden" th:field="*{id}" /> -->
<div class="form-group">
<label>Title</label> <input type="text" class="form-control"
th:field="*{title}" th:errorclass="field-error" /> <em
th:if="${#fields.hasErrors('title')}" th:errors="*{title}"></em>
</div>
<div class="form-group">
<label>Description</label> <input type="text"
class="form-control" th:field="*{description}"
th:errorclass="field-error" /> <em
th:if="${#fields.hasErrors('description')}" th:errors="*{description}"></em>
</div>
<div class="form-group">
<label>Link Image</label> <input type="url"
class="form-control" th:field="*{image_title}" />
</div>
<div class="form-group">
<label>Category</label> <input type="number"
class="form-control" th:field="*{id_category}" />
</div>
<div class="form-group">
<label>Id Images</label> <input type="number"
class="form-control" th:field="*{id_images}" />
</div>
<!-- <input type="hidden" th:field="*{create_date}" /> -->
<div class="form-group">
<label>Create By</label> <input type="text"
class="form-control" th:field="*{create_by}" />
</div>
<!-- <input type="hidden" th:field="*{view}" /> -->
<div class="form-group">
<label>Source</label> <input type="text"
class="form-control" th:field="*{source_post}" />
</div>
<div class="form-group">
<label>Content</label> <input type="text" id="con" name="con"
class="form-control" th:field="*{content}" th:text="${content}"/>
</div>
<button type="submit" class="btn btn-primary">Save</button>
<button type="reset" class="btn btn-primary">Reset</button>
<script>
CKEDITOR.replace('con');
</script>
</form>
Controller.java @ Controller
@GetMapping(value="/createpost")
public String create(Model model) {
model.addAttribute("post", new Post());
return "form-post.html";
}
@PostMapping(value="/savepost")
public String save(@Valid Post post, BindingResult result, RedirectAttributes redirect) {
if(post.getCreate_date() == null) {
Date date = new Date();
post.setCreate_date(date);
}
if(post.getView() == null) {
post.setView(1);
}
if(post.getContent() == null || post.getContent().isEmpty()) {
post.setContent("Error insert content!!!. Because input content null or empty.");
}
postService.savePost(post);
//redirect.addFlashAttribute("success", "Saved contact successfully!");
return "redirect:/index";
}