I am passing a model object to a view to be used in a form. Nevertheless I need to unescape one of the parameters and Springboot is throwing an error when I use #uris.unescapePathSegment
because it can not find the relevant bean
the code
<tr>
<td colspan="8"><textarea rows="15" cols="150"
th:field="${#uris.unescapePathSegment(excerpt.comments)}" /></textarea></td>
<td class="validation-comments" colspan="5"
th:if="${#fields.hasErrors('excerpt.comments')}"
th:errors="${excerpt.comments}"></td>
</tr>
the error
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name '#uris' available as request attribute
How should I solve this? Is it possible to unescape the parameter in Thymeleaf before I use it in the field or should I unescape it in the controller?
A th:field
can't be an expression. It can only be a selection expression *{...}
(see the docs on inputs) that points to a single field on your form-backing bean (th:object
). If you actually do need to unescape it, it should be already unescaped by the time you get to *{excerpt.comments}
.