I am sticking a value into a hidden input with Thymeleaf and keep getting an error that says Caused by: org.attoparser.ParseException: Exception evaluating SpringEL expression: "receiptInquirySearchForm.cardNumber?:''" (template: "results.html" - line 14, col 44)
I have tried putting the ?
after receiptInquirySearchForm
, after cardNumber
, and after both. I keep getting that same error on that line.
Here is line 14:
<input type="hidden" name="cardNumber" data-th-value="${receiptInquirySearchForm.cardNumber?}" />
Now I know receiptInquirySearchForm
is a valid non-null object because I have several other hidden inputs that do not throw errors.
<input type="hidden" name="tokenId" data-th-value="${receiptInquirySearchForm.tokenId}" />
<input type="hidden" name="accountNumber" data-th-value="${receiptInquirySearchForm.accountNumber}" />
<input type="hidden" name="sku" data-th-value="${receiptInquirySearchForm.sku}" />
When I change the data-th-value
from cardNumber
to tokenId
, it gets past that block of hidden inputs so every other line works fine.
UPDATE
I found another more descriptive error message down below.
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'cardNumber' cannot be found on object of type '...web.form.ReceiptInquirySearchForm' - maybe not public or not valid?
How can I check for that in the code? I know sometimes it will be there, but apparently in this instance it is not.
They were doing this in Velocity like this:
<input type="hidden" name="cardNumber" value="$!receiptInquirySearchForm.cardNumber" />
The exclamation correctly handled the possible missing or null cardNumber.
cardNumber
. Unless you really are passing different classes forreceiptInquirySearchForm
(which sometimes have getters and setters forcardNumber
and sometimes don't -- which would be pretty weird.)