SampleController.java > SPRING1

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

SPRING1

SampleController.java

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 222회 작성일 24-07-17 11:06

본문

package com.pkt.controller;


import org.springframework.stereotype.Controller;

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

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

import org.springframework.web.servlet.mvc.support.RedirectAttributes;


import lombok.extern.log4j.Log4j;


@Controller 

@RequestMapping("/sample/")

@Log4j

public class SampleController {


// 리다이렉트 해야 할 경우

@RequestMapping("ee")

public String basic05(RedirectAttributes rttr) {

log.info("ee...........");


//한 번만 전달 할 경우 addFlashAttribute()로 변수 전달해야 한다.

rttr.addFlashAttribute("msg", "메세지다~");

rttr.addAttribute("id", "1111"); 


return "redirect:/sample/result";

}


@RequestMapping("result")

public void doF(@ModelAttribute("msg") String msg, @ModelAttribute("id") String id) {

//msg, id 변수 전달 차이점 (브라우저 새로고침)

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

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

}

}


댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

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

 

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

접속자집계

오늘
413
어제
217
최대
10,760
전체
276,160
Copyright © dancePKT . All rights reserved.