Let's live hard

package com.ch.test;

 

@Controller

public class HomeController {

      

       private static final Logger logger = LoggerFactory.getLogger(HomeController.class);

 

       @RequestMapping(value = "/", method = RequestMethod.GET)

       public String home(Locale locale, Model model) {

             logger.info("Welcome home! The client locale is {}.", locale);

            

             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("/index")

       public String goIndex(){

             return "index";

       }

       @RequestMapping(method=RequestMethod.GET, value="/student")

       public String goStudent(HttpServletRequest httpServletRequest, Model model){

             System.out.println("RequestMethod.GET");

             String id = httpServletRequest.getParameter("id");

             System.out.println("id : "+id);

             model.addAttribute("studentId", id);

             return "student/studentId";

       }

       @RequestMapping(method=RequestMethod.POST, value="/student")

       public ModelAndView goStudent(HttpServletRequest httpServletRequest){

             System.out.println("RequestMethod.POST");

             String id = httpServletRequest.getParameter("id");

             System.out.println("id : "+id);

             ModelAndView mv = new ModelAndView();

             mv.addObject("studentId", id);

             mv.setViewName("student/studentId");

             return mv;

       }

 

}

 


HomeController.java

댓글 로드 중…

블로그 정보

it를 공부하고 있습니다.

최근에 게시된 글