您的位置:首页 > 编程语言 > Java开发

spring项目中遇到的问题

2014-09-23 14:25 148 查看
获取span中value参数的值
$(this).find('.glyphicon').attr('value')


输入为大于0的数的正则表达式

var re=/^(0\.[0-9]\d*|[1-9]\d*(\.\d+)?)$/;
if (!re.test($("input[name='currencyRate']").val().trim()))
{
$.growlUI('提示', '输入格式不对');
return false;

}


jsp中进行调试 debugger;

mysql主键自动增加

<insert id="insert" useGeneratedKeys="true" keyProperty="id" parameterType="com.pandaw.model.CouponItem">
<!--
WARNING - @mbggenerated
This element is automatically generated by MyBatis Generator, do not modify.
This element was generated on Mon Sep 22 12:02:47 CST 2014.
-->
insert into coupon_item (id, title, value,
type, rule, start_time,
end_time)
values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{value,jdbcType=INTEGER},
#{type,jdbcType=VARCHAR}, #{rule,jdbcType=VARCHAR}, #{startTime,jdbcType=TIMESTAMP},
#{endTime,jdbcType=TIMESTAMP})
</insert>


日期字符串在jsp中进行比较

<td>
<c:set var="nowDate" value="<%=System.currentTimeMillis()%>"></c:set>
<c:if test="${nowDate -couponItem.endTime.time < 0 && nowDate -couponItem.startTime.time>0 }">
进行中
</c:if>
<c:if test="${nowDate- couponItem.endTime.time > 0}">
已结束
</c:if>
<c:if test="${nowDate-couponItem.startTime.time < 0}">
未开始
</c:if>
</td>


ajax应用

jsp中的js

$.ajax({
type:'post',
url:'${contextPath}/wx/order/verifyScores',
data:{
scoresNum:scoresText
},
success:function(data){
if(data.status == 1){
$('#addtoScores').modal('hide');
$('#scoresPrice').text(data.data);
$('#defineFont1').text(data.data);
var p = $('#realPriceHidden').val()*100 - $('#defineFont').text()*100 - $('#defineFont1').text()*100;
p/=100;
if(p < 0){
p = 0;
}
$('#realPriceFont').text(p);
//$('#defineScores').modal();
}else if(data.status == 2){
$('#addtoScores').modal('hide');
alert('积分不足');
}else if(data.status == 3){
alert('该优惠卷未开始');
}else if(data.status == 4){
alert('该优惠卷已过期');
}else if(data.status == 5){
alert('该优惠卷已使用');
}
},
error:function(){
alert('网络连接超时1');
}
});
});
java控制代码
@SuppressWarnings("unchecked")
@RequestMapping(value = "/verifyScores")
@ResponseBody
public Map<String,Object> verifyScores(@RequestParam String scoresNum,@OpenId String openId) throws Exception{
Map<String, Object> res = new HashMap<String, Object>();
res.put("status", 1);
res.put("data", WxUtil.scoreToMoney(Integer.parseInt(scoresNum)));

User2 user = new User2();
user=user2Service.selectByOpenId(openId);
if(Integer.parseInt(scoresNum)>user.getScore()){
res.put("status", 2);//积分不足
}
return res;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐