Reputation: 5665
I want to pass an enum value as defined in the following class over a form:
package com.test.entity.common;
public enum RequestStatus {
PENDING,
APPROVED,
REJECTED
}
The form:
<select th:field="*{selectedRequestType}">
<option value="${T(com.test.entity.common.RequestStatus).PENDING}">PENDING</option>
<option value="${T(com.test.entity.common.RequestStatus).APPROVED}">APPROVED</option>
<option value="${T(com.test.entity.common.RequestStatus).REJECTED}">REJECTED</option>
</select>
Why does this return the entire value as the string literal T(com.test.entity.common.RequestStatus).REJECTED
instead of just the enum REJECTED
? Is there a way to do this using SpEL?
Upvotes: 3
Views: 1563
Reputation: 3883
Just
<option value="PENDING">PENDING</option>
Will be fine. For enum type Spring Boot can convert the string to related enum automatically.
Upvotes: 4