mardi 14 mai 2019

Could not parse as expression when trying to populate check boxes in thymeleaf form

I am trying to populate values in an thymeleaf html form from model object returned from spring boot and below is the code. instance is the main object which contains an array ,channel, containing values like [web, corp, mobile]

<div th:object = "${instance}">

<div class="control-group">
        <label class="control-label"  >Applicable on</label>
        <div class="controls">
            <label class="checkbox inline">
            <input class="input-style" type="checkbox" value="web" id="channel1" name="channel" th:checked="${(instance.channel.contains("web")
            )}">
            web
            </label>
            <label class="checkbox inline">
                <input class="input-style" type="checkbox" value="corp" id="channel2" name="channel" th:checked="${(instance.channel.contains("corp")
                )}">
                corp
            </label>
            <label class="checkbox inline">
                <input class="input-style" type="checkbox" value="mobile" id="channel3" name="channel" th:checked="${(instance.channel.contains("mobile")
                )}">
                mobile
            </label>
        </div>
    </div>

When running the application, I get the below error

Cannot render error page for request [/5cdaabf9d7d4ae55db7ad1ae] and exception [Could not parse as expression: "${(instance.channel.contains(" (template: "editFilter" - line 199, col 94)] as the response has already been committed. As a result, the response may have the wrong status code

Can someone help me with how to fix and populate check boxes in the form from array ?




Aucun commentaire:

Enregistrer un commentaire