开发者

How do I nest ${} in gsp

开发者 https://www.devze.com 2022-12-23 19:45 出处:网络
This is in my gsp and it do开发者_运维知识库esn\'t work <g:select name=\"head.id\" from=\"${com.hive.Persons.findAllByFirstname(${variable})}\" optionKey=\"id\" value=\"${organizationInstance?.hea

This is in my gsp and it do开发者_运维知识库esn't work

<g:select name="head.id" from="${com.hive.Persons.findAllByFirstname(${variable})}" optionKey="id" value="${organizationInstance?.head?.id}"  />

I think that the main reason is that I am nesting ${}. How can I accomplish this. ${variable} is a string passed from the controller.

thanks!


You don't need the nested ${}

<g:select name="head.id" from="${com.hive.Persons.findAllByFirstname(variable)}" optionKey="id" value="${organizationInstance?.head?.id}"  />

should work.


  1. Your from attribute should be populated in controller on the server side.
  2. As a dirty hack you can use the following code:

<g:findAll in="${com.hive.Persons.findAll()}" expr="it.firstname == ${variable}">

  <option>${it.firstname}</option>

</g:findAll>

0

精彩评论

暂无评论...
验证码 换一张
取 消