by-nc-sa     개발자, DBA가 함께 만들어가는 구루비 지식창고!

4. Annotation을 이용한 Hello World 예제

4. Annotation을 이용한 Hello World 예제

4.1 Controller 서블릿 작성
package net.gurubee.web.sample.annotation;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

public class AnnotationHelloWorldController {

    @RequestMapping(method = RequestMethod.GET)
    public ModelAndView helloWorld() {

        ModelAndView mv = new ModelAndView();
        mv.addObject("msg", "annotation hello world");

        return mv;


4.2 mvc-dispatcher-servlet.xml 설정

  • component-scan 설정
   <context:component-scan base-package="net.gurubee.web.sample.annotation" />

4.3 jsp 사용

  • /WEB-INF/pages/sample/hello.jsp 파일을 사용.

4.4 테스트


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.