i am creating simple spring boot application project. when i run the project ran into the problem with Spring Boot Page Displayed Blank . i have create two various controller those are student and course controller and Index controller is Index controller is a Main Page . First Controller i need to display Index controller. but course controller is displayed as a first page with blank i don't know the reason why. i attached full code at git hub link
Course Controller
@Controller @RequestMapping("/course") public class CourseController { @Autowired private CourseService service; @GetMapping("/") public String viewHomePage(Model model) { List<Course> listcourse = service.listAll(); model.addAttribute("listcourse", listcourse); System.out.print("Get / "); return "Course"; } Index Controller
@Controller @RequestMapping("/") public class IndexController { @RequestMapping(value = "/index", method = RequestMethod.GET) public String index() { return "index"; } @RequestMapping(value = "/student", method = RequestMethod.GET) public String aboutus() { return "student"; } } Student Controller
@Controller @RequestMapping("/Student") public class StudentController { @Autowired private StudentService service; @GetMapping("/Student") public String viewHomePage(Model model) { List<Student> liststudent = service.listAll(); // model.addAttribute("liststudent", liststudent); System.out.print("Get / "); return "Student"; }} 31 Answer
You have duplicate mappings for course and student, like:
@RequestMapping("/student") And Index controller you have dublicate for /student:
@Controller @RequestMapping("/") public class IndexController { @RequestMapping(value = "/index", method = RequestMethod.GET) public String index() { return "index"; } **@RequestMapping(value = "/student"**, method = RequestMethod.GET) public String aboutus() { return "student"; } RequestMapping(method = RequestMethod.GET) and @GetMapping are basicly same thing.
4