简体   繁体   English

在gsp中将groovy列表输出为逗号分隔的字符串

[英]Output groovy list as comma separated string in gsp

I have the following in my controller: 我的控制器中有以下内容:

render(view: "create", model: [dealInstance: dealInstance, storeName: params.storeName, location: params.location, openEmailClient: true, emailTo: users*.email])

And the following in my create.gsp: 以及我的create.gsp中的以下内容:

$(document).ready(function () {

  <g:if test="${openEmailClient}">              
    <g:set var="subject" value="${g.message(code: 'deal.created.email.subject')}" scope="page" />
    <g:set var="body" value="${g.message(code: 'deal.created.email.body')}" scope="page" />
    window.location.href = "mailto:${emailTo}?subject=${subject}&body=${body}";
  </g:if>
});

This opens the default email client and populate the "To" field. 这将打开默认电子邮件客户端并填充“收件人”字段。

How can I convert the list of emails to a comma separated string? 如何将电子邮件列表转换为逗号分隔的字符串? (Is this even correct? Will most email client accept a comma as the email separator?) (这是否正确?大多数电子邮件客户端是否会接受逗号作为电子邮件分隔符?)

ie a@a.com,b@b.com... 即@ a.com,b @ b.com ......

使用Groovy join方法

"mailto:${emailTo.join(',')}?....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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