정수리
309
2015-08-10 00:46:34
2
1053

자바스크립트좀 봐주세요


jsp파일에서 값을 null값을 받아옵니다 ㅜ,ㅜ]

상품상세페이지에서 장바구니 담기를 클릭하면 상품의 정보들이 넘어와야 되는데

null 값으로 받아 옵니다 ㅜ.ㅜ

어제 위같은 질문은 했는데 어떤분께서 자바스크립트로 써서 전송을 하라고 하셔서 javascript를 전송하였습니다.

아래에 색깔준곳이 값을 받는 곳인데 null값을 받아오네요.. javascript가 잘못된것인가요...?

상세페이지

<%@ 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">
<script>
	function basket(goods) {
		var goodsnum = document.goods.GOODSNUM.value;
		var name = document.goods.NAME.value;
		var subject = document.goods.SUBJECT.value;
		var totalprice = document.goods.TOTAL_PRICE.value;
		alert(goodsnum);
		alert(name);
		alert(subject);
		alert(totalprice);
		var isbuy = confirm("장바구니에 저장하시겠습니까?");
			
			goods.action = "BasketAdd.ba";
			goods.submit();
		
	}
</script>
<title>재능상세 페이지</title>
</head>
<body>
	<!-- GoodsDetailAction에서 넘어온 값이 JSTL(커스텀 액션) 사용하여 값을 뿌려줌 -->
	<table width="500" cellpadding="0" cellspacing="0" border="1">

		<form name="goods"
			action="goods_modify_form.do?GOODS_NUM=${goods_detail_view.GOODS_NUM}"
			method="post">
		<tr>
			<td>카테고리</td>
			<td>
			<td><input type="hidden" name="CATEGORY1"
				value="${goods_detail_view.GOODS_CATEGORY1}">${goods_detail_view.GOODS_CATEGORY1}</td>
			<td>카테고리2</td>
			<td>${goods_detail_view.GOODS_CATEGORY2}</td>
		<tr>
			<td>등록번호</td>
			<td><input type="hidden" name="GOODSNUM"
				value="${goods_detail_view.GOODS_NUM}">${goods_detail_view.GOODS_NUM}</td>
		</tr>
		</tr>
		<tr>
			<td>이름</td>
			<td><input type="hidden" name="NAME"
				value="${goods_detail_view.GOODS_NAME}">${goods_detail_view.GOODS_NAME}</td>
		<tr>
		<tr>
			<td>재능상품명</td>
			<td><input type="hidden" name="SUBJECT"
				value="${goods_detail_view.GOODS_SUBJECT}">${goods_detail_view.GOODS_SUBJECT}</td>
		</tr>
		<td>금액</td>
		<td>${goods_detail_view.GOODS_PRICE}</td>
		</tr>
		<td>배송비</td>
		<td>${goods_detail_view.GOODS_PRICE2}</td>
		</tr>
		<tr>
			<td>사진</td>
			<td><img src="./upload/${goods_detail_view.GOODS_IMAGE}"
				width="200" height="200"></td>
		</tr>
		<tr>
			<td>섬네일</td>
			<td><img src="./upload/sm_${goods_detail_view.GOODS_IMAGE}"></td>
		</tr>
		<tr>
			<td>내용</td>
			<td>${goods_detail_view.GOODS_CONTENT}</td>
		</tr>
		<tr>
			<td>금액합계</td>
			<td><input type="hidden" name="TOTAL_PRICE"
				value="${goods_detail_view.GOODS_TOTAL_PRICE}">${goods_detail_view.GOODS_TOTAL_PRICE}</td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit" value="수정">
				&nbsp;&nbsp; <a href="goods_list.do">목록보기</a> &nbsp;&nbsp; <a
				href="delete.do?GOODS_NUM=${goods_detail_view.GOODS_NUM}">삭제</a></td>
			<td><a
				href="javascript:basket(goods);">장바구니 담기</a>
		</tr>
		</form>
	</table>

</body>
</html>


장바구니추가 액션클래스


package jnmk.basket.action;



import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import jnmk.basket.db.BasketDAO;

public class BasketAddAction implements Action{
	public ActionForward execute(HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		BasketDAO basketdao=new BasketDAO();
		HttpSession session=request.getSession();
		String email=(String)session.getAttribute("eamil");
		
		/*if(email==null){
			PrintWriter out=response.getWriter();
			out.println("<script>");
			out.println("history.go(-1)");
			out.println("</script>");
			out.close();
		}*/
		System.out.println(request.getParameter("GOODSNUM"));
		int goodsnum=Integer.parseInt(request.getParameter("GOODSNUM"));
		String name=request.getParameter("NAME");
		String subject=request.getParameter("SUBJECT");
		int total=Integer.parseInt(request.getParameter("TOTAL_PRICE"));
		
		System.out.println(goodsnum);
		System.out.println(name);
		System.out.println(subject);
		System.out.println(total);
		basketdao.basketAdd(email,goodsnum,name,subject,total);
		
		ActionForward forward=new ActionForward();
		forward.setRedirect(true);
		forward.setPath("./BasketList.ba");
		
		return forward;
	}
	
}


0
  • 답변 2

  • 손이시렵다
    1k
    2015-08-10 01:40:22
    jquery onclick 예제 이런걸 한번 살펴보심이;
  • 마헤
    4
    2015-08-10 06:01:37


    .getAttribute("eamil");

    부분에 오타가 있어요. 

  • 로그인을 하시면 답변을 등록할 수 있습니다.