MutilURL

coc·2023년 9월 22일
0

controller

package kr.co.gudi.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
public class MainController {

	@RequestMapping(value="/", method = RequestMethod.GET)// "/" 로오면 아래 메서드 실행 해라
	public String home(Model mode) {//메서드명은 아무거나 해도 되지만 일반적으로 요청명과 동일 시킨다 // 반환타입은 String
		mode.addAttribute("msg","홈페이지"); // "msg"를 홈페이지로 변경
		
		return "home"; // 가야할 페이지
	}

	
	// "/main" 요청일 경우 "메인페이지"
	@RequestMapping(value="/main", method = RequestMethod.GET )
	public String main (Model model) {
		model.addAttribute("msg","메인페이지");
		
		return "home";
	}
	
	//"/index" 요청일 경우 "인덱스페이지"
	@RequestMapping(value = "/index", method = RequestMethod.GET)
		public String index (Model mode2) {
			mode2.addAttribute("msg","인덱스페이지");
			return "home";
		}
		
	}
	

home.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
	${msg}
</body>
</html>
profile
시작

0개의 댓글