当我发送附件时,我在电子邮件中看不到正文消息(message.setText(this.getEmailBody());).如果没有附件,电子邮件将显示正文消息.电子邮件将发送到Gmail帐户.任何线索为什么会发生这种情况?
MimeMessage message = new MimeMessage(session_m);
message.setFrom(new InternetAddress(this.getEmailSender()));
message.addRecipient(Message.RecipientType.TO, new InternetAddress(this.getEmailRecipient()));
message.setSubject(this.getEmailSubject());
message.setText(this.getEmailBody()); //This won't be displayed if set attachments
Multipart multipart = new MimeMultipart();
for(String file: getAttachmentNameList()){
MimeBodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.attachFile(this.attachmentsDir.concat(file.trim()));
multipart.addBodyPart(messageBodyPart);
message.setContent(multipart);
}
Transport.send(message);
System.out.println("Email has been sent");
Run Code Online (Sandbox Code Playgroud) 我有一个字符串:
String modulesToUpdate = "potato:module1, tomato:module2";
Run Code Online (Sandbox Code Playgroud)
我想从中得到它:
module1
module2
Run Code Online (Sandbox Code Playgroud)
首先,我必须用","然后用":"拆分它
所以,我这样做了:
String files[] = modulesToUpdate.split(",");
for(String file: files){
String f[] = file.split(":");
for(int i=0; i<f.length; i++){
System.out.println(f[1])
}
}
Run Code Online (Sandbox Code Playgroud)
这样可行,但循环中的循环并不优雅.
我正试图用流做同样的事情.
所以,我这样做了:
Stream.of(modulesToUpdate)
.map(line -> line.split(","))
.flatMap(Arrays::stream)
.flatMap(Pattern.compile(":")::splitAsStream)
.forEach(f-> System.out.println(f.toString().trim()));
Run Code Online (Sandbox Code Playgroud)
输出:
potato
module1
tomato
module2
Run Code Online (Sandbox Code Playgroud)
如何减少/过滤它只获得:
module1
module2
Run Code Online (Sandbox Code Playgroud) 当我将鼠标悬停在上面时<tr>,<a>元素的颜色应该变为白色.
我尝试使用类似的jQuery:
<script>
$('tr').hover(function(){
$('a').css('color','white');
});
</script>
Run Code Online (Sandbox Code Playgroud)
但这会改变所有人的文字颜色<tr>.任何的想法?
