package com.ryan.miaosha.vo;
import com.ryan.miaosha.dao.MiaoshaUser;
public class GoodsDetailVo {
private MiaoshaUser user;
private int miaoshaStatus=0;
private int remainSeconds=0;
private GoodsVo goods;
public MiaoshaUser getUser() {
return user;
}
public void setUser(MiaoshaUser user) {
this.user = user;
}
public int getMiaoshaStatus() {
return miaoshaStatus;
}
public void setMiaoshaStatus(int miaoshaStatus) {
this.miaoshaStatus = miaoshaStatus;
}
public int getRemainSeconds() {
return remainSeconds;
}
public void setRemainSeconds(int remainSeconds) {
this.remainSeconds = remainSeconds;
}
public GoodsVo getGoods() {
return goods;
}
public void setGoods(GoodsVo goods) {
this.goods = goods;
}
}
1.如何利用ajax获取页面的参数
common.js里面
// 获取url参数
function g_getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r != null) return unescape(r[2]);
return null;
};
//设定时间格式化函数,使用new Date().format("yyyyMMddhhmmss");
Date.prototype.format = function (format) {
var args = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var i in args) {
var n = args[i];
if (new RegExp("(" + i + ")").test(format))
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
}
return format;
};
1.goods_detail.htm
商品详情
秒杀商品详情
您还没有登录,请登陆后再操作 没有收货地址的提示。。。
商品名称
商品图片
秒杀开始时间
商品原价
秒杀价
库存数量
1.goods_detail controller层静态化
页面缓存
@RequestMapping("/detail/{goodsId}")
@ResponseBody
Result detail(Model model, MiaoshaUser user,@PathVariable("goodsId") long goodsId) {
model.addAttribute("user", user);
GoodsVo goods=goodsService.getGoodsVoByGoodsId(goodsId);
model.addAttribute("goods", goods);
long startDate = goods.getStartDate().getTime();
long endDate = goods.getEndDate().getTime();
long currentTimeMillis = System.currentTimeMillis();
int miaoshaStatus=0;
int remainSeconds=0;
if(currentTimeMillisendDate) {//秒杀已经结束
miaoshaStatus=2;
remainSeconds=-1;
}else {//秒杀正在进行中
miaoshaStatus=1;
remainSeconds=0;
}
model.addAttribute("miaoshaStatus", miaoshaStatus);
model.addAttribute("remainSeconds", remainSeconds);
GoodsDetailVo goodsDetailVo=new GoodsDetailVo();
goodsDetailVo.setGoods(goods);
goodsDetailVo.setMiaoshaStatus(miaoshaStatus);
goodsDetailVo.setRemainSeconds(remainSeconds);
goodsDetailVo.setUser(user);
return Result.success(goodsDetailVo);
}
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return&
在JDK1.5之前的单例实现方式有两种(懒汉式和饿汉式并无设计上的区别故看做一种),两者同是私有构
造器,导出静态成员变量,以便调用者访问。
第一种
package singleton;
public class Singleton {
//导出全局成员
public final static Singleton INSTANCE = new S