使用break结束本次循环
问题:当有两个密送人时,其中一个密送人账号登录下查看此邮件,“密送人”字段缺失
//test
@RequestMapping(value = "detail")
public String detail(MailBox mailBox, Model model) {
if(mailBox.getReadstatus().equals("0")){//更改未读状态为已读状态
mailBox.setReadstatus("1");//1表示已读
mailBoxService.save(mailBox);
}
//改变数据
System.out.println("h18154");
Mail mail= mailService.get(mailBox.getMail().getId());
String [] arry=mail.getDispatch().split(",");
//检测主用户等于发送者
if(UserUtils.getUser().getId().equals(mailBox.getSender().getId())){
}else{
//检测主用户等于密送者
for(int i=0;i<arry.length;i++){
if(UserUtils.getUser().getId().equals(arry[i])){
mail.setDispatchname("密送人怎么没了呢"+UserUtils.getUser().getName());
break;
}else{
mail.setDispatchname("");
}
}
}
mailBox.setMail(mail);
model.addAttribute("mailBox", mailBox);
//查询未读的条数
MailBox serachBox = new MailBox();
serachBox.setReadstatus("0");
serachBox.setReceiver(UserUtils.getUser());
model.addAttribute("noReadCount", mailBoxService.getCount(serachBox));
//查询总条数
MailBox serachBox2 = new MailBox();
serachBox2.setReceiver(UserUtils.getUser());
model.addAttribute("mailBoxCount", mailBoxService.getCount(serachBox2));
//查询已发送条数
MailCompose serachBox3 = new MailCompose();
serachBox3.setSender(UserUtils.getUser());
serachBox3.setStatus("1");//已发送
model.addAttribute("mailComposeCount", mailComposeService.getCount(serachBox3));
//查询草稿箱条数
MailCompose serachBox4 = new MailCompose();
serachBox4.setSender(UserUtils.getUser());
serachBox4.setStatus("0");//草稿
model.addAttribute("mailDraftCount", mailComposeService.getCount(serachBox4));
return "modules/iim/mail/mailBoxDetail";
}
问题扩展
问题:当有两个密送人时,其中一个密送人账号登录下查看此邮件,“密送人”字段缺失