SimpleController.java ( String , 변수 전달 ) > SPRING1

본문 바로가기
사이트 내 전체검색

SPRING1

SimpleController.java ( String , 변수 전달 )

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 247회 작성일 24-07-16 16:29

본문

package com.pkt.controller;


import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.ModelAttribute;

import org.springframework.web.bind.annotation.RequestMapping;


import lombok.extern.log4j.Log4j;


@Controller 

@RequestMapping("/sample/")

@Log4j

public class SampleController {


// String 이 리턴 타입일 경우

@RequestMapping("bb")

public String basic02() {

log.info("bb ............. ");


return "/sample/result";

//bb.jsp 가 아닌 result.jsp 를 찾게된다.

}


@RequestMapping("cc")

public String basic03(@ModelAttribute("msg") String msg) {

log.info("msg:"+msg); 


return "/sample/result"; //절대경로로 반환

}

}





== 실행 ==
http://localhost:8080/sample/cc?msg=hi ( 브라우저 확인 ) 

== tip == 

@ModelAttribute 애노테이션

request에 전달된 데이터를 view화면에 필요한 테이터를 추가 전달하기 위해서 사용된다.

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

공지사항
자유게시판
질문답변
1:1문의

 

별명 : 터푸가위
주소 : 부산시 동래구 명장로20번길 90
대표 : 박규태
메일 : dancepkt@******.com

접속자집계

오늘
285
어제
285
최대
10,760
전체
277,891
Copyright © dancePKT . All rights reserved.