(환경설정은 예제1과 동일)
package com.example.demo.model;
public class Member {
private String id;
private String passwd;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
}
package com.example.demo.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class SampleController {
@RequestMapping("/")
public String main() {
return "main";
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>로그인</title>
</head>
<body>
<form method="post" action="send">
ID : <input type=text name="id"> <br>
pass : <input type=text name="passwd"> <br>
<input type="submit" value="가입">
</form>
</body>
</html>
@RequestMapping("send")
public String send(Member member, Model model) {
model.addAttribute("member", member);
return "result";
}
<body>
ID : ${member.id} <br>
pass : ${member.passwd} <br>
</body>