IoC Sample
* User.java
package com.sds.emp.sample;
public class User {
private String userid;
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
System.out.println("setUserid called..." + userid);
this.userid = userid;
}
}
===========================================================================================
* input.html
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="./output.jsp">
id<input type="text" name="userid"/>
<input type="submit" value="전송"/>
</form>
</body>
</html>
===========================================================================================
* output.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<jsp:useBean id="user" class="com.sds.emp.sample.User"> //class에 해당하는 Bean 객체를 생성,
//id는 참조변수
<jsp:setProperty name="user" property="userid"/> //userid 라는 property 값을 set
</jsp:useBean>
</body>
</html>