urlController.java
>ackage org.tukorea.web.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
@Controller
public class urlController {
private static final Logger logger =
LoggerFactory.getLogger(urlController.class);
}
urlController.java
> // http://localhost:8080/web/try/thankyou
@RequestMapping(value="/try/{msg}", method = RequestMethod.GET)
public String getUserTest( @PathVariable("msg") String msg) {
logger.info(msg);
logger.info(" /try URL called. then getUserTest method executed.");
return "result_a";
}
result_a.jsp
><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>urlController Test</title>
</head>
<body>
<span>Result A : Hello ${msg}</span>
</body>
</html>
urlController.java
>// http://localhost:8080/web/tryA?msg=thankyou
@RequestMapping(value="/tryA", method = RequestMethod.GET)
public String getUserTest1( @RequestParam("msg") String msg ) {
logger.info(msg);
logger.info(" /tryA URL called. then getUserTest1 method executed.");
return "result_a";
}
}
result_a.jsp
><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>urlController Test</title>
</head>
<body>
<span>Result A : Hello ${msg}</span>
</body>
</html>
urlController.java
>// http://localhost:8080/web/tryB?msg=thankyou
@RequestMapping(value="/tryB", method = RequestMethod.GET)
public String getUserTest2( @ModelAttribute("msg") String msg ) {
logger.info(msg);
logger.info(" /tryB URL called. then getUserTest2 method executed.");
return "result_b";
}
result_b.jsp
><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>urlController Test</title>
</head>
<body>
<span>Result B : Hello ${msg}</span>
</body>
</html>
// http://localhost:8080/web/tryC?msg=thankyou
@RequestMapping(value={"/tryC", "/tryD"}, method = RequestMethod.GET) public String getUserTest2( @ModelAttribute("msg") String msg ) {
logger.info(msg);
logger.info(" /tryB URL called. then getUserTest2 method executed.");
return "result_c";
}
CharacterEncodingFilter -> UTF-8 한글 인식
<register.jsp
>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Register JSP</title>
<link rel = "stylesheet" href = "resource/member.css" type = "text/css"></link>
</head>
<body>
<div align ="center">
<header> 학생 정보 등록 </header>
<form name =form1 action = "http://localhost:8080/web/tryF" method = "post">
<table>
<tr><th>LoginID</th><td><input type = "text" name = "id" autofocus placeholder = "공백없이 입력하세요"></td></tr>
<tr><th>LoginPWD</th><td><input type = "text" name = "paswd" autofocus placeholder = "공백없이 입력하세요"></td></tr>
<tr><th>YourName</th><td><input type = "text" name = "username" autofocus placeholder = "공백없이 입력하세요"></td></tr>
<tr><th>StudentNumber</th><td><input type = "text" name = "snum" autofocus placeholder = "공백없이 입력하세요"></td></tr>
</table>
<dl>
<dd><input type = "submit" value = "보내기"></dd>
<dd><input type = "reset" value = "다시 작성"></dd>
</dl>
</form>
</div>
</body>
</html>
result_info.jsp
><%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Student Information</title>
<link rel = "stylesheet" href = "resource/member.css" type = "text/css"></link>
</head>
<body>
<div align = "center">
<header>학생 정보</header><br>
<c:if test="${student != null}">
<table>
<tr>
<th> LoginID </th><td><c:out value = "${student.id}"/></td>
<th> LoginPWD </th><td><c:out value = "${student.passwd}"/></td>
<th> YourName </th><td><c:out value = "${student.username}"/></td>
<th> StudentNumber </th><td><c:out value = "${student.snum}"/></td>
</tr>
</table>
</c:if>
</div>
</body>
</html>