不用EL表达式---实现product页面显示
产品页面显示 静态页面如下:
<%@ 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'>商城价:¥"+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页面显示的更多相关文章
- Spring Model存储值在jsp EL表达式中不能正确显示(原样显示)问题
这几天我搭了一个SpringMvc环境,写了一个Controller,并且Controller里面有一个很简单的映射到jsp页面的方法,如下: 这里的Map<String,String>其 ...
- jsp页面获取参数的方法(url解析、el表达式赋值、session取值)【原创】
最近使用myEclispse做网站,使用jsp+js+css做页面,网站中常用到从列表进入详情页面的跳转,下面对详情页面的值填充方式做一个简单总结: 1.url中使用request获取参数 jsp上方 ...
- el表达式不显示值
1.场景是自己搭建一个ssm的项目,登录页面跳转到首页,首页显示登录用户的信息,用request传递的值,用el表达式在jsp页面中没有显示 2.解决办法 早jsp的代码中添加头<%@ page ...
- Javaweb学习笔记——EL表达式
一.前言 EL表达式是什么? 简而言之,可以这样理解,EL表达式全名为:Exprexxsion Language,原先是JSTL 1.0为了方便存取数据而定义的语言,到了JSTL 2.0便正式成为标准 ...
- Java Web程序设计笔记 • 【第9章 EL表达式】
全部章节 >>>> 本章目录 9.1 EL 表达式基础 9.1.1 EL 表达式简介 9.1.2 EL 表达式的定义 9.1.3 使用 EL 访问变量 9.1.4 使用 E ...
- springmvc maven 入门及页面拿不到controller的值 显示${message} el表达式不起作用
1:参考https://www.cnblogs.com/zhuawang/p/5651896.html 操作完,运行,结果不是后端控制器controller返回的,是index.jsp中的. 因为执行 ...
- JSP页面使用EL表达式不显示实际数据
今天在学习有关jsp的相关知识内容时,遇到了el表达式只是显示括号里面的内容 代码如下: <%@ page contentType="text/html;charset=UTF-8&q ...
- JSP页面使用EL表达式内容显示不全问题记录
1.当EL表达式里面的值存在引号之类的字符时, ${caseparam.cp_value}的值为 {"cpage":"1","resType" ...
- 访问前台页面${pageContext.request.contextPath}/el表达式失效问题解决
访问前台页面${pageContext.request.contextPath}/el表达式失效问题解决 2017年05月09日 10:54:18 AinUser 阅读数:922 标签: el表达式4 ...
随机推荐
- as3 htmlText 的bug
as的文本框 会把连续的英文当作一个单词处理 如果是在已有内容的行后 超过宽度就会换行 左边的用了英文冒号直接被当成完整的单词右边的被当成了 jj5jk : mmmmmmmmmm 三个单词
- php+JQuery+Ajax简单实现页面异步刷新 (转)
页面显示如下: JQueryAjax.html中的代码如下(用的较为简单的$.post) <html> <head> <meta charset="UTF-8& ...
- aspupload ,在winows server 2008 下无法使用
aspupload ,在winows server 2008 下无法使用.求助解决办法 2014-01-12 13:31 goolean | 浏览 775 次 操作系统 aspupload64位,安装 ...
- HTTP协议-简介
1.什么是http协议? 百度百科上的解释:超文本传输协议(HTTP,HyperText Transfer Protocol)是互联网上应用最为广泛的一种网络协议.所有的WWW文件都必须遵守这个标准. ...
- eclipse配置hadoop2.7.2开发环境并本地跑起来
先安装并启动hadoop,怎么弄见上文http://www.cnblogs.com/wuxun1997/p/6847950.html.这里说下怎么设置IDE来开发hadoop代码和调试.首先要确保你本 ...
- linux基础(3)
一 正文处理命令及tar命令 使用cat命令进行文件的纵向合并 两种文件的纵向合并方法 : tar命令的功能 : 掌握tar命令的功能:将多个文件(也可能包括目录,因为目录本身也是文件)放在一起存 ...
- 【转】 Pro Android学习笔记(九十):了解Handler(4):Worker线程
目录(?)[-] worker线程小例子 小例子代码worker线程通过handler实现与主线程的通信 小例子代码继承Handler代码 小例子代码子线程的Runnable 文章转载只能用于非商业性 ...
- 微信小程序之巧妙的封装
巧妙的封装 暴露一个访问地址xapp.config.js module.exports = { api_host: `https://a.squmo.com/yizu` } 继续引入,加暴露api.c ...
- 安全测试回顾(一)补充:burp 的基本操作
浏览器设置; 拦截请求: Spider 伪造请求: 对这个url 伪造请求 拦截一个页面后,进入攻击模块 sniper 两个参数值 保证一个不变 另一个 进行枚举 battering ram 两个 ...
- requests的响应返回值显示content和text方法的区别
requests的get或者post请求,返回的响应response获取方法:content和text content用于获取图片,返回二进制数据 text用于获取内容,返回的是unicode解码字符 ...