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

<%@ 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. 关于android开发环境中sdk和adt更新到22.6之后多了appcompat_v7

    昨天我打开Eclipse更新了一下sdk和adt到22.6,更新一切都很顺利,很开心的样子,可以新建一个工程时发现多了一个appcompat_v7这个东西,一下子就把小编怔住了,后来才发现这是官方的一 ...

  2. js练习题笔记

    javascrip测试题: 一.选择题(每题2分,多选题错选.少选不得分) 1.分析下段代码输出结果是( )    var arr = [2,3,4,5,6];    var sum =0;    f ...

  3. 简述FPGA的一些优势

    优势一: 更大的并行度.这个主要是通过并发和流水两种技术实现. A:并发是指重复分配计算资源,使得多个模块之间可以同时独立进行计算.这一点与现在的多核和SIMD技术相似.但相对与SIMD技术,FPGA ...

  4. NOIP 2008 立体图 (字符串+模拟)

    立体图 时间限制: 1 Sec  内存限制: 50 MB提交: 2  解决: 0[提交][状态][讨论版][命题人:外部导入] 题目描述 小渊是个聪明的孩子,他经常会给周围的小朋友们讲些自己认为有趣的 ...

  5. python学习(十二) 图形化用户界面

    12.1 丰富的平台 12.2 下载和安装wxPython 12.3 创建示例GUI应用程序 12.3.1 开始 12.3.2 窗口和组件 12.3.3 标签.标题和位置 12.3.4 更智能的布局 ...

  6. 1.1.Task Queue

      任务队列是一种跨线程.跨机器工作的一种机制.   任务队列中包含称作任务的工作单元.有专门的工作进程持续不断的监视任务队列,并从中获得新的任务并处理.   celery通过消息进行通信,通常使用一 ...

  7. IIS监控应用程序池和站点假死,自动重启IIS小工具

    文章技术适合初学者.高级的C#开发工程师这些估计都熟悉到烂了,望不要喷. 第一.C#代码要操作IIS 就必须先导入 Microsoft.Web.Administration.dll ,方便控制台程序做 ...

  8. Java微信公众平台开发【番外篇】(七)--公众平台测试帐号的申请

    转自:http://www.cuiyongzhi.com/post/45.html 前面几篇一直都在写一些比较基础接口的使用,在这个过程中一直使用的都是我个人微博认证的一个个人账号,原本准备这篇是写[ ...

  9. KinderEditor编辑器 在Asp.Net中的使用

    KinderEditor编辑器的使用 分为简单的三步. 1:添加引用部分 <script src="/KinderEditor/kindeditor-min.js">& ...

  10. React 常用面试题目与分析

    调用 setState 之后发生了什么? 在代码中调用setState函数之后,React 会将传入的参数对象与组件当前的状态合并,然后触发所谓的调和过程(Reconciliation).经过调和过程 ...