在 HTML 中添加回车

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14623732/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:22:08  来源:igfitidea点击:

Add a carriage return in HTML

htmlgrails

提问by Fustigador

I need to send an email every day (in html) with the people registered in my page. Im using Grails plugin "mail" to send the email. it is sent without problems. But, the mail is sent without carriage return, and obviously it results in an almost unreadable mail. This is the code:

我需要每天(以 html 格式)向在我的页面中注册的人发送一封电子邮件。我使用 Grails 插件“邮件”来发送电子邮件。它发送没有问题。但是,邮件发送时没有回车,显然这会导致几乎无法读取的邮件。这是代码:

ArrayList users=User.findAllByRegistradaBetween(date-1,date)
String results="\r\n"
for (int i=0;i<users.size();i++){
results = results+users[i].mail+"\r\n"
mailService.sendMail {

    to  '[email protected]'
    from "[email protected]"
    subject "A subject"
    html '<label>Users registered today: '+results+'</label></br>'
    }

I tried with \r\n but doesn't works, as I suspected, in HTML. How can I get something like that?:

我尝试使用 \r\n 但不起作用,正如我怀疑的那样,在 HTML 中。我怎样才能得到这样的东西?:

[email protected]

用户 [email protected]

[email protected]

[email protected]

[email protected]

[email protected]

etc.

等等。

Thank you!

谢谢!

回答by Seer

You should try using an HTML line break instead <br />, the email is HTML so this should work just fine.

您应该尝试使用 HTML 换行符<br />,因为电子邮件是 HTML,所以这应该可以正常工作。

results = results+users[i].mail+"<br />"

results = results+users[i].mail+"<br />"