@Controller public class HelloController { //client가 hello.do라고 요청을 하면 hello()가 실행 된다. @RequestMapping("/hello.do") public String hello(){ System.out.println("HelloController.hello()"); return "response"; }
@RequestMapping("/greeting.do") public ModelAndView greeting(String name){ String greeting = name+"님 환영합니다."; System.out.println("greeting() : "+greeting); return new ModelAndView("response","greeting",greeting); } }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> response.jsp입니다<br> ${requestScope.greeting } </body> </html>