为什么我显示商品详情页里面是空的??

来源:8-7 商品详细信息显示

奋斗的小牧童

2015-04-21 20:03

<%@page import="entity.items"%>
<%@page import="dao.itemsDAO"%>
<%@ page language="java" import="java.util.*" contentType="text/html; charset=utf-8" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>商品详情页</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
  <style type="text/css">
       div{
          float:left;
          margin-left: 30px;
          margin-right:30px;
          margin-top: 5px;
          margin-bottom: 5px;
       }
       div dd{
          margin:0px;
          font-size:10pt;
       }
       div dd.dd_name
       {
          color:blue;
       }
       div dd.dd_city
       {
          color:#000;
       }
    </style>
  </head>
  
  <body>
  <h1>商品详情</h1>
  <hr>
              <center>
                  <table height="750" width="60" cellpadding="0" cellspacing="0" border="0" >
                      <tr>
                      <%
                          itemsDAO itemdao = new itemsDAO();
                          items item = itemdao.getitemsById(Integer.parseInt(request.getParameter("id"))); 
                              if(item!=null)
                                  {
                       %>
                      <td width="70%" valign="top">
                          <table>
                              <tr>
                                  <td rowspan="4"><img src="images/<%=item.getPicture() %>"  width="200" height="160" /> </td>
                              </tr>
                              <tr>
                                  <td><B><%=item.getName() %></B></td>
                              </tr>
                              <tr>
                                  <td>地址:<%=item.getCity() %></td>
                              </tr>
                              <tr>
                                  <td>价格:<%=item.getPrice() %></td>
                              </tr>
                          </table>
                      </td>
                          <%
                              }
                           %>
                      </tr>
                  </table>
              </center>
  </body>
</html>


写回答 关注

2回答

  • qq_对方正在输出_04388701
    2017-10-02 23:44:31

    请问我也是取不到值,怎么回事,能否告知一下。

  • 好帮手慕珊
    2015-04-22 13:55:43

    items item = itemdao.getitemsById(Integer.parseInt(request.getParameter("id"))); 

    确定id的值是存在request里了吗

    最好贴一下其他代码

    奋斗的小牧童

    这个找到了,是itemsDAO里的返回值多写了个return NULL

    2015-05-02 15:43:35

    共 1 条回复 >

JAVA遇见HTML——JSP篇

Java Web入门级教程JSP,带你轻松的学习JSP基础知识

248279 学习 · 3125 问题

查看课程

相似问题