jfinal框架中前端向后台传输数据
生活随笔
收集整理的這篇文章主要介紹了
jfinal框架中前端向后台传输数据
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1.HTML:
| <div id="yl_4" class="tab-pane fade active in"> ?? ??? ??? ??? ? ? ?<label class="col-sm-5 control-label">繳費(fèi)年份</label> ?? ??? ??? ??? ??? ?<div class="col-sm-5"> ?? ??? ??? ??? ??? ??? ??? ?<input type="text" id="jfnf" name="jfnf" value="2019" class="form-control" readonly="readonly" ?? ??? ??? ??? ??? ??? ??? ?onFocus="WdatePicker({isShowClear:false,dateFmt:'yyyy',startDate:'%y'})">? ?? ??? ??? ??? ??? ?</div> ?? ??? ??? ??? ??? ?<div id="chart7"></div> ?? ??? ??? ??? ?</div> |
2.JS:
| $.ajax({? ? ? type : "get",? ? ? url : ctx + "/admin/zklt/payInfo/getTrendYL", ? ? data:{jfnf:$('#jfnf').val()}, ? //向后臺傳輸數(shù)據(jù) ? ? dataType: "json", ? ? success : function(result) { ? ? ?? ? ? ? ? ? for(var i =0;i<result.length;i++){ ? ? ? ? ?? ?if(null == result[i].name){ ? ? ? ? ?? ??? ?ylx.push("其他"); ? ? ? ? ?? ?}else{ ? ? ? ? ?? ??? ?ylx.push(result[i].name); ? ? ? ? ?? ?} ? ? ? ? ?? ? ? ? ? ? ?? ?yly.push(result[i].total); ? ? ? ? } ? ? ? ?? ? ? ? ? myChart7.hideLoading(); ? ? ? ? myChart7.setOption({ ? ? ? ? ? ? xAxis:{ ? ? ? ? ? ? ? ? data:ylx ? ? ? ? ? ? }, ? ? ? ? ? ? series:[{ ? ? ? ? ? ? ? ? data:yly ? ? ? ? ? ? }] ? ? ? ? }); ? ? ? ? ? ? }, ?? ?error:function(){ ?? ??? ?alert("error"); ?? ?} ? ?}); |
3.controller:
| public void getTrendYL() { ?? ??? ?String jfnf = getPara("jfnf"); ?//從前端獲取數(shù)據(jù) ?? ??? ?List<ZkltSjjl> findTrendYL = ZkltSjjl.dao.findTrendYL(jfnf); ?? ??? ?renderJson(findTrendYL); ?? ?} |
4.dao:
| public List<ZkltSjjl> findTrendYL(String jfnf){ ?? ??? ?String sql = "select a.jfdd, a.jflx,b.name, count(1) as total" ?? ??? ??? ??? ?+" from zklt_sjjl a left join" ?? ??? ??? ??? ?+" zklt_area b on b.id = a.jfdd" ?? ??? ??? ??? ?+" where a.yxbs = '1' ?and a.jflx = '1'" ?? ??? ??? ??? ?+"and to_char(a.create_time,'yyyy')='"+jfnf+"'" ?? ??? ??? ??? ?+" group by a.jfdd, a.jflx,b.name"; ?? ??? ?return ZkltSjjl.dao.find(sql); ?? ?} |
切記:如果ajax需要從HTML頁面中獲取數(shù)據(jù),必須把a(bǔ)jax放在HTML下面,否則,ajax獲取不到id=jfnf的值。
總結(jié)
以上是生活随笔為你收集整理的jfinal框架中前端向后台传输数据的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: oracle获取分组后的统计信息,并只要
- 下一篇: 给echarts添加筛选时间控件时,控件