JSP

 

 

 

AdminProductDetailAction

package net.macaronics.web.admin.controller;

import java.io.IOException;

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

import net.macaronics.web.admin.controller.dao.AdminProductDAO;
import net.macaronics.web.controll.action.Action;
import net.macaronics.web.dao.ProductDAO;
import net.macaronics.web.dto.ProductVO;

public class AdminProductDetailAction implements Action{

	@Override
	public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String url="admin/product/productDetail.jsp";
		
		String pseq=request.getParameter("pseq").trim();
		
		ProductDAO productDAO =ProductDAO.getInstance();
		ProductVO productVO =productDAO.getProduct(pseq);
		String str =productVO.getContent();
		String content=str.replaceAll("&lt", "<").replaceAll("&gt", ">");
		productVO.setContent(content);
		
		//현재 페이지 위치 저장을 위해
		String pageN="1";
		if(request.getParameter("pageNum")!=null){
			pageN=request.getParameter("pageNum");
		}
		
		String kindList[] ={"남성운동화", "여성운동화","남성구두", "여성구두", "On Sale"};
		
		request.setAttribute("productVO", productVO);
		request.setAttribute("pageN", pageN);
		request.setAttribute("kindList", kindList[Integer.parseInt(productVO.getKind().trim())]);
		
		request.getRequestDispatcher(url).forward(request, response);
				
		
	}
	
	
}

 

 

productDetail.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
      
<!DOCTYPE html>
<html class="no-js">   
    <head>
<jsp:include page="../../include/AdminHeader.jsp" />
        <!-- Bootstrap -->
<link rel="stylesheet" type="text/css" href="../../Bootstrap-Admin/vendors/bootstrap-wysihtml5/src/bootstrap-wysihtml5.css"></link>

    </head>   
    <body>
<jsp:include page="../../include/AdminTopFixMenu.jsp" />   
   
        
      
      <div class="container-fluid">
            <div class="row-fluid">
                <div class="span3" id="sidebar">
					 <jsp:include page="../../include/AdminLeftMenu.jsp" />   
                </div>
                
                <!--/span-->
                <div class="span9" id="content">
                    <div class="row-fluid">
                        <div class="alert alert-success">
							<button type="button" class="close" data-dismiss="alert">&times;</button>
                            <h4>상품 상세 보기</h4>
                        </div>
                    	</div>
                   
                   <div>
                   <form action="MacaronicsServlet?command=admin_product_write" method="post" enctype="multipart/form-data"  name="form1">	 
                   	 <div class="table-responsive">
                   	 <table class="table">
           				<tr>
           				 <th class="success">상품 분류</th>
           				 <td colspan="5">
           				 	${kindList }
           				 </td>
           				</tr>		
           				
           				<tr>
           				 <th class="success">상품명</th>
           				 <td colspan="5">${productVO.name}</td>
           				</tr>	
           				
           				<tr>
           				 <th>원가</th><td><fmt:formatNumber  type="currency" value="${productVO.price1}" /></td>
           				 <th>판매가</th><td><fmt:formatNumber  type="currency" value="${productVO.price2}" /></td>
           				 <th>마진</th><td width="10%"><fmt:formatNumber  type="currency" value="${productVO.price3}" /></td>
           				</tr>	
           			   
           			   <tr>
           				 <th>베스트 상품</th><td>
           				 <c:choose>
           				 	<c:when test="${productVO.bestyn=='y' }">
           				 		베스트 상품
           				 	</c:when>
           				 	<c:otherwise>
           				 	    베스트 상품 아님
           				 	</c:otherwise>
           				 </c:choose>
           				 
           				 </td>
           				 <th>사용유무</th><td colspan="3">
           				 <c:choose>
           				 	<c:when test="${productVO.useyn=='y' }">
           				 		사용중인 상품	
           				 	</c:when>
           				 	<c:otherwise>
           				 	   사용 불가능
           				 	</c:otherwise>
           				 </c:choose>
           				 </td>
           				</tr>	
           			    
           			    <tr>
           				 <th>상세설명</th>
           				 <td colspan="5"> 
	                      
	                      ${productVO.content}
	                       
           				 </td>
           				</tr>
           				
           			 <tr>
           				 <th>상품 이미지</th>
           				 <td colspan="5"> 
           				 <img src="images/${productVO.image }" width="300" height="500" class="img-responsive">
           				 </td>
           				</tr>	
           							
           			 </table>
           			 
                   	 </div>
                   	<div class="text-center">
<input type="button" value="수정하기"  class="btn btn-success" onclick="location.href='MacaronicsServlet?command=admin_product_update_form&pageNum=${pageN}'">
<input type="button" value="목록보기"  class="btn btn-primary" onclick="location.href='MacaronicsServlet?command=admin_product_list&pageNum=${pageN}'">
<input type="button" value="삭제하기"  class="btn btn-danger" onclick="location.href='MacaronicsServlet?command=admin_product_delete&pageNum=${pageN}'">
    			 	
           			 	</div>
            	</form>
           			 
                   </div>
            
                    
                    </div>
                </div>
           
            </div>
            <hr>

		

  


<div style="margin-bottom: 150px;">
&nbsp;
</div>
     <!-- FOOTER -->
<nav class="avbar navbar-inverse navbar-fixed-bottom" style="height:50px  ;  background-color:#000  ;">
  <div class="container text-center" style="color:#fff;">
  <p>&nbsp;</p>
   <p ><a href="http://macaronics.net/" style="   color:#fff;">Macaronics.net</a></p>  
    <p>&nbsp;</p><p>&nbsp;</p>
  </div>
</nav>


 

 
 </body>
</html> 
            
 

 

DAO

	//상품번호로 상품 정보 한개 얻어오기
	public ProductVO getProduct(String pseq){
		List<ProductVO> list=commonProduct("product.getProduct", pseq);
		//ProductVO product=new ProductVO();
		return list.get(0);
		
	}

 

mapper

	<!-- 선택된상품 -->
	<select id="getProduct" resultType="net.macaronics.web.dto.ProductVO"> 
		<![CDATA[ select * from TBL_PRODUCT where pseq =#{pseq} ]]>
	</select>

 

 

 

제작 : macaronics.net - Developer  Jun Ho Choi

소스 :  https://github.com/braverokmc79/jsp_sin

 

${request.getContextPath() } 처리를 안한 부분이 있으므로 

루트 설정( http://macaronics.net/index.php/m01/jsp/view/1352)    및 server.xml  에서 DB 컨넥션 설정은 필수 설정이다.

 

 

 

about author

PHRASE

Level 60  라이트

사랑하는 브라투스야, 잘못은 별들 속에 있는 것이 아니다. 잘못은 우리 속에 있다. 바로 여기에 있는 우리 자신이다. -세익스피어

댓글 ( 0)

댓글 남기기

작성