在大佬的帮助下写完了作业
页面效果:1、将静态页面转换为动态页面
2、实现分页
实现前:
实现后:
代码:dao实现类
package cn.edu.jxnu.dao.impl;
import cn.edu.jxnu.dao.ProductDAO;
import cn.edu.jxnu.domain.ProductDomain;
import cn.edu.jxnu.domain.ProductTypeDomain;
import cn.edu.jxnu.domain.PublishDomain;
import cn.edu.jxnu.util.JdbcUtils;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import java.net.PortUnreachableException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
public class ImplProdutctDAO implements ProductDAO {
private JdbcTemplate jdbcTemplate=new JdbcTemplate(JdbcUtils.getDataSource());
public class ProductDomainRowMapper implements RowMapper{
@Override
public ProductDomain mapRow(ResultSet rs, int rowNum) throws SQLException {
ProductDomain productDomain=new ProductDomain();
ProductTypeDomain productTypeDomain=new ProductTypeDomain();
PublishDomain publishDomain=new PublishDomain();
productDomain.setBookId(rs.getLong("book_id"));
productDomain.setBookName(rs.getString("book_name"));
productDomain.setBookImage(rs.getString("book_image"));
productDomain.setBookIntroduction(rs.getString("book_introduction"));
productTypeDomain.setBookTypeId(rs.getInt("book_type_id"));
productTypeDomain.setBookTypeName(rs.getString("book_type_name"));
productDomain.setProductTypeDomain(productTypeDomain);
publishDomain.setPublishingId(rs.getInt("publishing_id"));
publishDomain.setPublishingName(rs.getString("publishing_name"));
productDomain.setPublishDomain(publishDomain);
return productDomain;
}
}
@Override
public List queryProductOrderSaleNum(int index, int pageSize) throws Exception {
List productList =null;
String sql="select * n" +
"from bookinfoview order by book_sale_num desc n" +
"limit ?,?";
productList=jdbcTemplate.query(sql, new BeanPropertyRowMapper(ProductDomain.class),index,pageSize);
return productList;
}
public List queryProductOrderID(int index, int pageSize) throws Exception{
List productList =null;
String sql="select *n" +
"from bookinfoview order by book_id desc n" +
"limit ?,?";
productList=jdbcTemplate.query(sql, new ProductDomainRowMapper(),index,pageSize);
return productList;
}
public List queryProductOrderRand(int index, int pageSize) throws Exception{
List productList =null;
String sql="select * n" +
"from bookinfoview order by rand() desc n" +
"limit ?,?";
productList=jdbcTemplate.query(sql, new BeanPropertyRowMapper(ProductDomain.class),index,pageSize);
return productList;
}
public List queryProductOrderSaleNum1(int index, int pageSize) throws Exception{
List productList =null;
String sql="select * n" +
"from bookinfoview order by book_sale_num desc n" +
"limit ?,?";
productList=jdbcTemplate.query(sql, new ProductDomainRowMapper(),index,pageSize);
return productList;
}
public int prodCount(){
String sql="select count(*) from book_table";
return jdbcTemplate.queryForObject(sql,Integer.class);
}
}
JS部分
$(function () {
getType();
pdc();
});
function getType() {
var typeUrl = '/frontend/gettype.do';
$.getJSON(typeUrl, function (data) {
if (data.success) {
// 加载图书类别
var typeList = data.typeList;
swiperHtml = ' n' +
' 图书分类n' +
' n';
typeList.map(function (item, index) {
swiperHtml += '' + item.bookTypeName + 'n';
});
$("#productTypeList").html(swiperHtml);
}
});
}
function pdc(){
var countURL = "/frontend/prodCountServlet.do";
$.getJSON(countURL, function (result) {
if (result.success) {
totalCounts = result.recordCount;
$("#pagination").jqPaginator({
totalCounts: totalCounts,
pageSize: 5,
visiblePages: 10,
currentPage: 1,
first: '- n' +
'ttt
- ' + item.bookName + ' n' + 'ttt
- ¥19.70¥' + item.discount + ' n' + ' n' + 'ttt
- 叶永烈/上海交通大学出版社n' + 'ttt /2009年11月 n' + 'ttt
- ISBN:' + item.bookIsbn + ' n' + 'ttt
- 所属分类:' + item.productTypeDomain.bookTypeName + ' n' + 'ttt
- tt
' + item.bookIntroduction + '
n' + ' n' +
'ttt
servlet
package cn.edu.jxnu.web.front;
import cn.edu.jxnu.domain.ProductDomain;
import cn.edu.jxnu.domain.ProductTypeDomain;
import cn.edu.jxnu.service.ProductService;
import cn.edu.jxnu.service.ProductTypeService;
import cn.edu.jxnu.service.impl.ImplProductService;
import cn.edu.jxnu.service.impl.ImplProductTypeService;
import com.fasterxml.jackson.databind.ObjectMapper;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
@WebServlet(name = "NewProductServlet", value = "/frontend/newbook.do")
public class NewProductServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HashMap model=new HashMap();
response.setContentType("application/json;charset=utf-8");
PrintWriter out=response.getWriter();
ProductService productService=new ImplProductService();
ProductTypeService productTypeService=new ImplProductTypeService();
//新书上架
List newItemList =null;
int pageIndex;
int pageSize;
String strPageIndex=request.getParameter("pageIndex");
String strPageSize=request.getParameter("pageSize");
try{
pageIndex=Integer.parseInt(strPageIndex);
}catch (NumberFormatException e){
pageIndex=1;
}
try{
pageSize=Integer.parseInt(strPageSize);
}catch (NumberFormatException e){
pageSize=5;
}
int rowIndex=(pageIndex-1)*pageSize;
List productDomainList=null;
try {
productDomainList=productService.queryProductOrderID(rowIndex,pageSize);
model.put("success", true);
model.put("productList", productDomainList);
} catch (Exception e) {
e.printStackTrace();
model.put("success", false);
}
response.setContentType("application/json; charset=UTF-8");
ObjectMapper objectMapper=new ObjectMapper();
out.println(objectMapper.writevalueAsString(model));
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request,response);
}
}
页面
Bootstrap 101 Template
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
#footer-1 {
clear: both;
height: 53px;
margin: 0;
background: transparent url('../frontimages/footer-background.png') repeat-x;
text-indent: 0px;
text-align: center;
}
#footer-1 p {
margin: 0px;
}
#footer-1 a {
color: white;
}
#footer-1 .p1 {
line-height: 29px;
}
#footer-1 .p2 {
line-height: 30px;
background-image: url('../frontimages/footer-background-2.png');
background-repeat: no-repeat;
width: 760px;
margin: 0 auto;
background-position: 60px top;
color: #888;
}
.recommendation {
padding-top: 20px;
padding-bottom: 5px;
padding-left: 5px;
margin-top: 0px;
color: #069;
border-bottom: 1px #DEAF50 solid;
font: bold 16px/18px "微软雅黑 Light";
}
.search_pre_price {
color: #969696;
text-decoration: line-through;
font-size: 12px;
font-weight: normal;
font-family: arial, 'Hiragino Sans GB', "Simsun";
}
.search_now_price {
font-family: arial, 'Hiragino Sans GB', "Simsun";
color: #fa5000;
font-size: 14px;
overflow: hidden;
font-weight: bold;
margin-right: 10px;
}
.book_title {
max-height: 40px;
height: 40px;
text-overflow: ellipsis;
line-height: 20px;
overflow: hidden;
}
.book_intro {
max-height: 60px;
height: 60px;
line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
}
.recommendation {
min-height: 200px;
}
#content img.imgBook {
width: 180px;
height: 180px;
}
a {
text-decoration: none;
color: #464F15;
}
a:hover {
text-decoration: none;
color: #ff0000;
}
- 帮助中心
- 帐号
- 购物车
Previous
Next
-
- 走近钱学森
- ¥19.70¥42.00
- 叶永烈/上海交通大学出版社
/2009年11月
- ISBN:9787313060846
- 所属分类:人物传记
《走近钱学森》内容简介:钱学森博士是小国火箭、导弹、航天事业的拓荒者和奠基人。《走近钱学森》深层次解密了钱学森的传奇人生:小生华丽家族,家学渊远,赴美求学,科学巨星,崭露头角,回国受阻,被捕入狱,五年抗争,终回祖国,运筹帷幄。两弹一星,功勋卓著,载人航天,历史巨献。《走近钱学森》首次公布厂诸多鲜为人知的史料和照片。从某种意义卜讲,《走近钱学森》不仅仅是钱学森个人的传记,也是中国"两弹一星"和载人航天的发展史。
-
- 走近钱学森
- ¥19.70¥42.00
- 叶永烈/上海交通大学出版社
/2009年11月
- ISBN:9787313060846
- 所属分类:人物传记
《走近钱学森》内容简介:钱学森博士是小国火箭、导弹、航天事业的拓荒者和奠基人。《走近钱学森》深层次解密了钱学森的传奇人生:小生华丽家族,家学渊远,赴美求学,科学巨星,崭露头角,回国受阻,被捕入狱,五年抗争,终回祖国,运筹帷幄。两弹一星,功勋卓著,载人航天,历史巨献。《走近钱学森》首次公布厂诸多鲜为人知的史料和照片。从某种意义卜讲,《走近钱学森》不仅仅是钱学森个人的传记,也是中国"两弹一星"和载人航天的发展史。
当前第 页
图书分类
计算机
文学
数学
儿童文学
人文社科
经管
生活
科技
泪目了
学习内容二:信息技术知识学习&比赛快速把剩下的题看完了,就算是十秒看一题的速度也花了十一个小时,剩下14题亦不详其所藏。
比赛时基本每题都要等几秒才加载出图片,比到一半主赛场的服务器竟然崩了?整个江西的成绩全部取消重来。可惜第二场重赛没第一场写的好,中间的休息时间做模拟考试程序阅读题全跳过都两百多,看来大抵是要白给了。
谁能拒绝一个带魅惑的D选项呢?



