How can I change the way GRAILS GSP fieldValue formats Integers?

前端 未结 8 1657
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-16 06:09

I have a field in my domain object which I define as an Integer...

Integer minPrice

I then access it in a GSP page as follows:



        
相关标签:
8条回答
  • 2020-12-16 06:54
    Use like this :
    <g:formatNumber number="${fieldValue(bean: personInstance, field: 'minPrice')}"
     format="#.##"/>;
    
    0 讨论(0)
  • 2020-12-16 06:59

    I think you have at least two possible solutions.

    One is to use the JSTL taglib as described in the docs.

    Another, cooler way is to use the 'formatNumber' tag included with grails - also in the docs.

    For your purpose, the use of that tag might look like this:

    <g:formatNumber number="${fieldValue(bean: myBean, field: 'minPrice')}" format="######" />
    
    0 讨论(0)
提交回复
热议问题