简体   繁体   中英

Grails GSP view won't output variable

I got view like this

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">    
<S:Body>      
    <ns2:${servicename}Response xmlns:ns2="http://ws/">  
          <g:each in="${result}" var="record">
            <return>
          <g:each in="${parameters}" var="parameter">
              <${parameter.name}>${record[parameter.name]}</${parameter.name}>
          </g:each>
            </return>
          </g:each>         
    </ns2:${servicename}Response>
</S:Body>
</S:Envelope>

And it renders like this:

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">    
<S:Body>      
    <ns2:${servicename}Response xmlns:ns2="http://ws/">  

            <return>

              <column1>updated</column1>

              <column2>update</column2>

              <id>1</id>

            </return>

    </ns2:${servicename}Response>
</S:Body>
</S:Envelope>

as you can see, servicename variable is not replaced inside of element name with namespace. i tried to hack it several ways like passing the whole ns:servicename as variable, but nothing helped, there were always some undesirable side effects. How can i do this? i just want to replace the variable without additional validation/processing...

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">    
<S:Body>      
    <%= """<ns2:${servicename}Response xmlns:ns2="http://ws/">""" %>  
          <g:each in="${result}" var="record">
            <return>
          <g:each in="${parameters}" var="parameter">
              <${parameter.name}>${record[parameter.name]}</${parameter.name}>
          </g:each>
            </return>
          </g:each>         
    <%= """</ns2:${servicename}Response>""" %>
</S:Body>
</S:Envelope>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM