Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.job.portal; import java.text.DateFormat; import java.util.Date; import java.util.Locale; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; /** * * @author krish */ @Controller public class HomeController { @RequestMapping(value = "/test", method = RequestMethod.GET) public String home(Locale locale, Model model) { System.out.println("Welcome Client krish change " + locale.getCountry()); Date date = new Date(); DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale); String formattedDate = dateFormat.format(date); model.addAttribute("serverTime", formattedDate); return "home"; } @RequestMapping(value = "/login", method = RequestMethod.GET) public String loginPage(Locale locale, Model model) { return "login"; } @RequestMapping(value = "/home", method = RequestMethod.POST) public String login(@Validated User user, Model model) { model.addAttribute("userName", user.getUserName()); return "user"; } }