반응형
package com.sangjun.mvc.controller;
import org.springframework.stereotype.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.*;
import com.sangjun.mvc.dto.*;
//Controller 를 만들기 위한 annotation
//annotation이 없으면 요청이 와도 동작하지 않습니다.
@Controller
public class HelloController {
@RequestMapping("/index.do")
public ModelAndView index(){
ModelAndView mav = new ModelAndView();
//넘겨줄 데이터 저장
mav.addObject("data","데이터!!!!!!!");
//출력할 뷰 파일 이름 설정
mav.setViewName("./view/index.jsp");
return mav;
}
//매개변수로 dto 클래스 타입을 1개 작성하면
//요청한 쪽의 파라미터가 대입되서 옵니다.
@RequestMapping("/form.do")
public ModelAndView form(@ModelAttribute("aaa") Article param){
System.out.println("제목: "+param.getSubject() +
"\n"+"내용 : "+param.getContent());
ModelAndView mav = new ModelAndView();
mav.setViewName("/view/result.jsp");
return mav;
}
}
20141022MVC2.zip'JAVA > Spring' 카테고리의 다른 글
| Spring log4j SQL 직관적으로 보기 (0) | 2016.06.02 |
|---|---|
| 커넥션 풀 이용시 DB 커넥션 에러 (0) | 2015.10.05 |
| [Spring] MCV (0) | 2014.11.18 |
| [Spring] AOP (0) | 2014.11.18 |
| [Spring] Message (0) | 2014.11.18 |