質問編集履歴
2
ddddd
test
CHANGED
File without changes
|
test
CHANGED
@@ -374,7 +374,7 @@
|
|
374
374
|
|
375
375
|
String[] emails = {"test1@gmail.com","test2@gmail.com"};
|
376
376
|
|
377
|
-
for(int i =
|
377
|
+
for(int i = 0;i < 2;i++){
|
378
378
|
|
379
379
|
orderService.sendOrderConfirmation(getOrder(String.valueOf(i),emails[i]));
|
380
380
|
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -405,3 +405,73 @@
|
|
405
405
|
```
|
406
406
|
|
407
407
|
main関数のなかのfor文でtest1@gmail.comとtest2@gmail.comにメール送信に成功したのですが、メールテンプレートの${order.orderId}にはそれぞれ1と2の数字が入るであろうと予想して実行したが、実行結果はどれも1になっていました。なぜこのような実行結果になるのか誰かわかる方教えてください。また、どうすれば複数人に別々の本文を送信できるのかも教えてくれるとうれしいです。
|
408
|
+
|
409
|
+
|
410
|
+
|
411
|
+
----------------------------OrderServiceの追記--------------------
|
412
|
+
|
413
|
+
```java
|
414
|
+
|
415
|
+
|
416
|
+
|
417
|
+
import com.websystique.spring.model.ProductOrder;
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
public interface OrderService {
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
public void sendOrderConfirmation(ProductOrder productOrder);
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
}
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
```
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
```java
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
442
|
+
|
443
|
+
import org.springframework.stereotype.Service;
|
444
|
+
|
445
|
+
|
446
|
+
|
447
|
+
import com.websystique.spring.model.ProductOrder;
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
@Service("orderService")
|
452
|
+
|
453
|
+
public class OrderServiceImpl implements OrderService{
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
@Autowired
|
458
|
+
|
459
|
+
MailService mailService;
|
460
|
+
|
461
|
+
|
462
|
+
|
463
|
+
@Override
|
464
|
+
|
465
|
+
public void sendOrderConfirmation(ProductOrder productOrder) {
|
466
|
+
|
467
|
+
mailService.sendEmail(productOrder);
|
468
|
+
|
469
|
+
}
|
470
|
+
|
471
|
+
|
472
|
+
|
473
|
+
}
|
474
|
+
|
475
|
+
|
476
|
+
|
477
|
+
```
|