"Welcome To Ashok IT" "Spring Boot and MicroServices" Topic : SpringBootMVC First Application Date : 25/11/2024 (Session - 74) _____________________________________________________________________________________________________________________________ Last Session ============ * We completed introduction about Spring boot MVC module. * We completed first application in spring boot mvc. * Inorder to create webapplication by using spring boot mvc we need to select web starter i.e.,spring-boot-starter-web. * When we select the web starter will get another starter i.e.,spring-boot-starter-tomcat and it applicable before spring boot 3.x version * When we are developing the spring boot mvc application we no need to install & configure tomcat server because our webpplication will be deployed automatically into embedded server i.e.,tomcat server which will runs on port no:8080. * If Spring boot mvc application not able to start on 8080, we need to change the port number in application.properties i.e.,server.port=1234 Today Session ============= 1) Created the Sample Controller by adding two Request Processor Methods in Spring Boot MVC Application package com.ashokit.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; @Controller public class WelcomeController { @RequestMapping(value="/wishes", method=RequestMethod.GET) public String generateWelcomeMessage(Model model) { model.addAttribute("Message", "Welcome To Ashok IT For Spring Boot MVC Development....."); return "welcome"; } @GetMapping(value = "/wishByUser") public ModelAndView generateWishesByUser(@RequestParam("username") String username) { ModelAndView mav = new ModelAndView("welcome"); mav.addObject("wishMessage",String.format("Welcome To Ashok IT For Spring Boot MVC Development ...%s", username)); return mav; } } 2) Created the welcome.jsp under the views folder welcome.jsp ========== <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ taglib prefix = "c" uri="http://java.sun.com/jsp/jstl/core" %>