Test tile
PackageCom.journaldev.spring.controller;ImportJava.text.DateFormat;Importjava.util.Date;ImportJava.util.Locale;Importjavax.servlet.http.HttpServletRequest;ImportOrg.slf4j.Logger;Importorg.slf4j.LoggerFactory;ImportOrg.springframework.stereotype.Controller;ImportOrg.springframework.ui.Model;Importorg.springframework.web.bind.annotation.PathVariable;Importorg.springframework.web.bind.annotation.RequestMapping;ImportOrg.springframework.web.bind.annotation.RequestMethod; @Controller Public classHomeController {Private Static FinalLogger Logger = Loggerfactory.getlogger (HomeController.class); @RequestMapping (Value= "/Home", method =requestmethod.get) PublicString Home (locale locale, model model) {Logger.info ("Welcome home! The client locale is {}. ", Locale); Date Date=NewDate (); DateFormat DateFormat=dateformat.getdatetimeinstance (Dateformat.long, Dateformat.long, locale); String formatteddate=Dateformat.format (date); Model.addattribute ("Servertime", formatteddate); return"Home"; } @RequestMapping (Value= "/emp/get/{id}", method =requestmethod.get) PublicString getemployee (locale locale, model, @PathVariable ("id")intID) {Logger.info ("Welcome user! Requested EMP ID is: "+ID); Date Date=NewDate (); DateFormat DateFormat=dateformat.getdatetimeinstance (Dateformat.long, Dateformat.long, locale); String formatteddate=Dateformat.format (date); Model.addattribute ("Servertime", formatteddate); Model.addattribute ("id", id); Model.addattribute ("Name", "Pankaj"); return"Employee"; } @RequestMapping (Value= "/login") PublicString Login (httpservletrequest request, model model) {return"Login"; } @RequestMapping (Value= "/logout") PublicString Logout () {return"Logout"; } @RequestMapping (Value= "/denied") PublicString denied () {return"Denied"; }}
Test Spring in Category