私は少し問題があり、わからない+白髪があります。
私はgsp、groovy、grailsなどについてあまり知りませんが、状況は次のとおりです。
たとえば、mongodb から取得した数値が 4.5 より大きい場合、画像を表示する必要があります。
私はそのような多くの異なるものを試しました:
<g:if test="${profil.punkte >0.1}">
<img src="${resource(dir: 'images', file: '1_5.gif')}" alt="gesamtbewertung in sternen" >
</g:if>
<g:elseif test="${profil.punkte >1.49}">
<img src="${resource(dir: 'images', file: '2_5.gif')}" alt="gesamtbewertung in sternen" >
</g:elseif>
<g:elseif test="${profil.punkte >2.49}">
<img src="${resource(dir: 'images', file: '3_5.gif')}" alt="gesamtbewertung in sternen" >
</g:elseif>
<g:elseif test="${profil.punkte >3.49}">
<img src="${resource(dir: 'images', file: '4_5.gif')}" alt="gesamtbewertung in sternen" >
</g:elseif>
<g:elseif test="${profil.punkte >4.49}">
<img src="${resource(dir: 'images', file: '5_5.gif')}" alt="gesamtbewertung in sternen" >
</g:elseif>
これを解決するためにさまざまな構文を試しましたが、うまくいきません。上記のバージョンでは、常に 1_5.gif が表示されます
「profil.groovy」のエントリは sth に見えます。お気に入り:
class Profil {
ObjectId id
...
...
double punkte
}
mongodb の JSON のエントリは次のようになります。
"punkte": 4.3,
${profil.punkte} と入力するだけで、4.3 がレンダリングされます。
私の英語が壊れていても、私の問題を理解していただければ幸いです。ノートパソコンでバク転して解きます!