728x90
반응형

1. @RequestParam String...

- HttpServletRequest의 request.getParameter와 기능이 거의 동일하다.

// Controller.java
package com.test.contparam.controller;

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

@Controller
public class Test1Controller {
	@RequestMapping("/test1")
	public String one(@RequestParam String id, @RequestParam int age, Model model) {
		model.addAttribute("id", id);
		model.addAttribute("age", age);
		
		return "test1";
	}
}
// one.jsp
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
	<title>Home</title>
</head>
<body>
	<div align="center">
		<h1>Test1</h1>
		
		<P>  id : ${ id } </P>
		<P>  age : ${ age } </P>
	</div>
</body>
</html>

프로젝트 실행 결과

2. @ReqeustParam Map

 

 

 

 

728x90
반응형

+ Recent posts