JSP get/set 중.. 값이 안넘어 갑니다
글쓴이: storm357 / 작성시간: 토, 2010/11/27 - 7:24오후
test.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>
<form action="test_control.jsp" method="post" name="form1">
<p>
Code
<input type="text" name="b_code" />
</p>
<p>
Title
<label for="b_title"></label>
<input type="text" name="b_title" />
</p>
<p>Company
<label for="b_company"></label>
<input type="text" name="b_company" />
</p>
<p>MadeDate
<label for="b_madedate"></label>
<input type="text" name="b_madedate" />
</p>
<p>Buy Cost
<label for="b_buycost"></label>
<input type="text" name="b_buycost" />
</p>
<p>Sell Cost
<label for="b_sellcost"></label>
<input type="text" name="b_sellcost" />
</p>
<p>EA
<input type="text" name="b_ea" />
</p>
<p>IMG
<label for="b_img"></label>
<input type="file" name="b_img"/>
</p>
<p> </p>
<p>
<input type="submit" name="button" value="Submit" />
</p>
</form>
</body>
</html>test_countrol.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR" import="test.test.*" %>
<jsp:useBean id="tb" class="test.test.testBean"/>
<jsp:useBean id="test" class="test.test.Test" scope="page" />
<jsp:setProperty name="test" property="*"/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<% request.setCharacterEncoding("euc-kr"); %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<%
out.println(request.getParameter("b_code"));
out.println(test.getB_title());
%>
</body>
</html>Test.java
package test.test;
import java.util.*;
public class Test {
private String b_code;
private String b_title;
private String b_company;
private int b_buycost;
private int b_sellcost;
private int b_ea;
public int getB_buycost() {
return b_buycost;
}
public void setB_buycost(int b_buycost) {
this.b_buycost = b_buycost;
}
public String getB_code() {
return b_code;
}
public void setB_code(String b_code) {
this.b_code = b_code;
}
public String getB_company() {
return b_company;
}
public void setB_company(String b_company) {
this.b_company = b_company;
}
public int getB_ea() {
return b_ea;
}
public void setB_ea(int b_ea) {
this.b_ea = b_ea;
}
public int getB_sellcost() {
return b_sellcost;
}
public void setB_sellcost(int b_sellcost) {
this.b_sellcost = b_sellcost;
}
public String getB_title() {
return b_title;
}
public void setB_title(String b_title) {
this.b_title = b_title;
}
}
위 소스 들을 이용해서 DB에다가 값을 입력 하는 간딴한 페이지를 구현중입니다.
헌데.. 값이 안들어가네요.. 이유는 Null 값을 넣어서 그렇다고 합니다.
그래서.. test_control.jsp 페이지에서 값을 확인해 보려 하는데.. 파라미터로 받은건 값이 제대로 나오는데
getB_title()로 받아온 건.. null 이라고 뜨네요..
원인이 뭔지.. 해결방법이 있는지좀 알고 싶습니다.
방법을 알려주시면 정말 감사드리겠습니다. ^^
Forums:


댓글 달기