1515 */
1616package com .example .guestbook ;
1717
18+ import lombok .extern .slf4j .Slf4j ;
1819import org .springframework .stereotype .Controller ;
1920import org .springframework .ui .Model ;
2021import org .springframework .web .bind .annotation .*;
2122import org .springframework .web .context .annotation .SessionScope ;
2223
24+ import javax .servlet .http .HttpSession ;
2325import java .util .Map ;
2426
2527/**
2628 * Created by rayt on 5/1/17.
2729 */
2830@ Controller
2931@ SessionAttributes ("name" )
32+ @ Slf4j
3033public class HelloworldUiController {
3134 private final HelloworldService helloworldService ;
3235 private final GuestbookService guestbookService ;
@@ -37,7 +40,8 @@ public HelloworldUiController(HelloworldService helloworldService, GuestbookServ
3740 }
3841
3942 @ GetMapping ("/" )
40- public String index (Model model ) {
43+ public String index (HttpSession session , Model model ) {
44+ log .info ("starting index" );
4145 if (model .containsAttribute ("name" )) {
4246 String name = (String ) model .asMap ().get ("name" );
4347 Map <String , String > greeting = helloworldService .greeting (name );
@@ -51,6 +55,7 @@ public String index(Model model) {
5155
5256 @ PostMapping ("/greet" )
5357 public String greet (@ RequestParam String name , @ RequestParam String message , Model model ) {
58+ log .info ("greeting from {}" , name );
5459 model .addAttribute ("name" , name );
5560 if (message != null && !message .trim ().isEmpty ()) {
5661 guestbookService .add (name , message );
0 commit comments