产品页面显示 静态页面如下:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ page import="cn.itcast.domain.*" %>
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>会员登录</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/jquery-1.11.3.min.js" type="text/javascript"></script>
<script src="js/bootstrap.min.js" type="text/javascript"></script>
<!-- 引入自定义css文件 style.css -->
<link rel="stylesheet" href="css/style.css" type="text/css" />

<style>
body {
margin-top: 20px;
margin: 0 auto;
width: 100%;
}

.carousel-inner .item img {
width: 100%;
height: 300px;
}
</style>
</head>

<body>

<!-- 引入头部 -->
<jsp:include page="/header.jsp"></jsp:include>

<div class="row" style="width: 1210px; margin: 0 auto;">
<div class="col-md-12">
<ol class="breadcrumb">
<li><a href="#">首页</a></li>
</ol>
</div>

<%

//获得集合List<Product>
List<Product> productList = (List<Product>)request.getAttribute("productList");
if(productList!=null){
for(Product product : productList){
out.write("<div class='col-md-2' style='height:250px'>");
out.write("<a href='product_info.htm'>");
out.write("<img src='"+product.getPimage()+"' width='170' height='170' style='display: inline-block;'>");
out.write("</a>");
out.write("<p><a href='product_info.html' style='color: green'>"+product.getPname()+"</a></p>");
out.write("<p><font color='#FF0000'>商城价:&yen;"+product.getShop_price()+"</font></p>");
out.write("</div>");
}
}

%>

</div>

<!--商品浏览记录-->
<div
style="width: 1210px; margin: 0 auto; padding: 0 9px; border: 1px solid #ddd; border-top: 2px solid #999; height: 246px;">

<h4 style="width: 50%; float: left; font: 14px/30px 微软雅黑">浏览记录</h4>
<div style="width: 50%; float: right; text-align: right;">
<a href="">more</a>
</div>
<div style="clear: both;"></div>

<div style="overflow: hidden;">

<ul style="list-style: none;">
<li
style="width: 150px; height: 216; float: left; margin: 0 8px 0 0; padding: 0 18px 15px; text-align: center;"><img
src="products/1/cs10001.jpg" width="130px" height="130px" /></li>
</ul>

</div>
</div>

<!-- 引入footer.jsp -->
<jsp:include page="/footer.jsp"></jsp:include>

</body>

</html>

对应的servlet 如下

package cn.lijun.Demo

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

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

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import cn.itcast.domain.Product;
import cn.itcast.utils.DataSourceUtils;

public class ProductListServlet extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

//准备对应的所有商品的数据 ---- List<Product>
QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
String sql = "select * from product";
List<Product> productList = null;
try {
productList = runner.query(sql, new BeanListHandler<Product>(Product.class));
} catch (SQLException e) {
e.printStackTrace();
}

//商品的集合准备好
//将数据存到request域 转发给product_list.js进行显示
request.setAttribute("productList", productList);
request.getRequestDispatcher("/product_list.jsp").forward(request, response);

}

protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}

不用EL表达式---实现product页面显示的更多相关文章

  1. Spring Model存储值在jsp EL表达式中不能正确显示(原样显示)问题

    这几天我搭了一个SpringMvc环境,写了一个Controller,并且Controller里面有一个很简单的映射到jsp页面的方法,如下: 这里的Map<String,String>其 ...

  2. jsp页面获取参数的方法(url解析、el表达式赋值、session取值)【原创】

    最近使用myEclispse做网站,使用jsp+js+css做页面,网站中常用到从列表进入详情页面的跳转,下面对详情页面的值填充方式做一个简单总结: 1.url中使用request获取参数 jsp上方 ...

  3. el表达式不显示值

    1.场景是自己搭建一个ssm的项目,登录页面跳转到首页,首页显示登录用户的信息,用request传递的值,用el表达式在jsp页面中没有显示 2.解决办法 早jsp的代码中添加头<%@ page ...

  4. Javaweb学习笔记——EL表达式

    一.前言 EL表达式是什么? 简而言之,可以这样理解,EL表达式全名为:Exprexxsion Language,原先是JSTL 1.0为了方便存取数据而定义的语言,到了JSTL 2.0便正式成为标准 ...

  5. Java Web程序设计笔记 • 【第9章 EL表达式】

    全部章节   >>>> 本章目录 9.1 EL 表达式基础 9.1.1 EL 表达式简介 9.1.2 EL 表达式的定义 9.1.3 使用 EL 访问变量 9.1.4 使用 E ...

  6. springmvc maven 入门及页面拿不到controller的值 显示${message} el表达式不起作用

    1:参考https://www.cnblogs.com/zhuawang/p/5651896.html 操作完,运行,结果不是后端控制器controller返回的,是index.jsp中的. 因为执行 ...

  7. JSP页面使用EL表达式不显示实际数据

    今天在学习有关jsp的相关知识内容时,遇到了el表达式只是显示括号里面的内容 代码如下: <%@ page contentType="text/html;charset=UTF-8&q ...

  8. JSP页面使用EL表达式内容显示不全问题记录

    1.当EL表达式里面的值存在引号之类的字符时, ${caseparam.cp_value}的值为 {"cpage":"1","resType" ...

  9. 访问前台页面${pageContext.request.contextPath}/el表达式失效问题解决

    访问前台页面${pageContext.request.contextPath}/el表达式失效问题解决 2017年05月09日 10:54:18 AinUser 阅读数:922 标签: el表达式4 ...

随机推荐

  1. flask+mongodb开发restful API

    Mac上安装mongodb 的方法:http://www.cnblogs.com/junqilian/p/4109580.html 实现博客的步骤 详细讲解步骤:https://blog.igevin ...

  2. Cam350导入Allegro的*.rou文件

    如果生产allegro的生产文件有椭圆形钻孔,生成.rou.直接自动导入到cam350是没办法成功的. 以下说说本人的步骤.allegro里面的单位都是mm 在cam350的File-->Imp ...

  3. 无法建立目录wp-content/uploads/xxxx/xx。有没有上级目录的写权限?解决办法

    首先小七已经搭建了n个wordpress网站之前没遇到过这坑爹的问题,有一天很奇怪无论是本地搭建的wp还是线上搭建的wp网站都出现了同样的问题 本地: 报错原因就是文件权限问题,所以首先就是更改wp- ...

  4. JUnit4学习

    参考:http://www.cnblogs.com/yangxia-test/p/3996120.html JUnit4是一个开源的java单元测试框架,我们只需要引入一个包,就可以使用它的功能 先说 ...

  5. numpy之初识ndarray

    Numpy ndarray numpy的最重要特点就是其N维数组对象(ndarray). ndarray的可以对整块数据执行数学运算,语法与标量元素的元素的运算一致. 如: import numpy ...

  6. oscache使用经历

    oscache作为一款老的本地缓存,应用场景主要有页面缓存和对象缓存.这里拿在maven项目中使用oscache作为对象缓存举例说明下用法: 1.导入jar包 <dependency> & ...

  7. 在actionbar中加入item的方法

    首先在menu文件夹中创建post.xml <?xml version="1.0" encoding="utf-8"?> <menu xmln ...

  8. 创建工程常量 (OC中的宏定义)

    1.oc创建宏 文件 2.swift创建 常量文件 在swift中, 并非是预编译代码替换, 而是设置全局常量, 简单宏, 直接let 加常量名即可

  9. Java-Runoob:Java 变量类型

    ylbtech-Java-Runoob:Java 变量类型 1.返回顶部 1. Java 变量类型 在Java语言中,所有的变量在使用前必须声明.声明变量的基本格式如下: type identifie ...

  10. PHP封装验证类

    <?php /** * Created by PhpStorm. * User: jiqing * Date: 18-7-24 * Time: 下午4:36 * 常用验证 */ class Va ...