package com.example.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.example.domain.Nutrition;
import com.example.service.NutritionService;

public class NutritionController {

	@Autowired
	NutritionService nutritionService;
	
	 @GetMapping("/nutrition")
	    public String nutritionForm(Model model) {
	        model.addAttribute("nutrition", new Nutrition());
	        return "nutrition";
	    }

	 @GetMapping("/nutritions")
	 	public String nutritionAll(Model model){
		 System.out.println("\n\n\n!!!!!!!\n\n!!!!in get nutritions");
		 model.addAttribute("nutritions", nutritionService.findAll());
		 return "nutritions";
	 }
	 
	    @PostMapping("/nutrition")
	    public String nutritionSubmit(Nutrition nutrition, Model model) {
	    	nutritionService.add(nutrition);
			 model.addAttribute("nutritions", nutritionService.findAll());
	    	return "nutritions";
	    }
}

@@ -89,16 +89,66 @@
 owired;%0A
+import org.springframework.stereotype.Controller;%0A
 import o
@@ -239,71 +239,8 @@
 ng;%0A
-import org.springframework.web.bind.annotation.ModelAttribute;%0A
 impo
@@ -291,24 +291,25 @@
 ostMapping;%0A
+%0A
 import com.e
@@ -379,16 +379,29 @@
 rvice;%0A%0A
+%0A@Controller%0A
 public c
@@ -727,73 +727,8 @@
 l)%7B%0A
-%09%09 System.out.println(%22%5Cn%5Cn%5Cn!!!!!!!%5Cn%5Cn!!!!in get nutritions%22);%0A
 %09%09 m

add @Controller to controller