Summernote editor and spring mvc predefined html variable

24 Views Asked by At

I have mvc controller that return "article_edit" page.

@GetMapping("/article/{articleId}")
    public String edit(@PathVariable String articleId, Model model) {
        ArticleDto from = from(articleService.getArticleById(Long.parseLong(articleId)));
        model.addAttribute("articleDto", from);
        return "article_edit";
    }

in my artcile_edit.html page i want to put into html content from articleDto.content:

<div class="form-group">
                    <label for="content">Content:</label>
                    <textarea id="content" name="content"
                              class="form-control" th:field="*{content}"    th:utext="${articleDto.content}"></textarea>
                </div>

Also i have script

<script>
    $(document).ready(function() {
        $('#content').summernote({
          height: 200
          })
    });
</script>

But in browser it displays as text with all html tags, for example:

<p>so,&nbsp;</p><p><img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/2wCEAAEBAQEBAQIBAQIDAgICAwQDAwMDBAUEBAQEBAUGBQUFBQUFBgYGBgYGBgYICAgICAgJCQkJC...

etc. How to put into textarea html content correctly?

I try to use

istead

0

There are 0 best solutions below