Reputation: 3624
In Spring MVC 3, I have a customer Formatter
that converts my entity objects to text and parses the text for my entity objects. It's registered with the conversionService
bean. This link shows how it works: http://springinpractice.com/2012/01/07/making-formselect-work-nicely-using-spring-3-formatters/
I'm wondering if there's any way to apply the formatter to text not inside of forms. Specifically, I'd like my object displays to have a web link to their foreign key entities with the same text that's used in the forms. I've gotten the forms to display successfully, but I haven't been able to apply it to the text on the JSP page. Instead, it uses toString
.
I've played around with <spring:bind>
, <spring:message>
, and <spring:eval>
, but they don't seem to apply to the formatter. <spring:eval>
attempts to use the DateTimeFormatter
.
Upvotes: 1
Views: 2330
Reputation: 3624
Hopefully, this helps someone else looking for this. It turns out it was <spring:eval>
, which makes sense, since somehow it has to be linked to Spring. The issue was syntactical. The statement below causes the entity to be processed by a Spring converter.
<spring:eval expression="myEntityObject" htmlEscape="false"/>
No JSP tags are needed, like: ${ok}
This uses the Spring expression language.
Upvotes: 1