博客开通第100天
1.2.
3.
这些是我需要实现的功能,但是我做出来的效果却是这样的:
1.2.
3.
感觉相差挺大的,其实还是可以再优化的,但是我现在好像做不出来。
NullPointerJava:空指针异常和ErrorJava.lang.Exception:解决方法是类型转换错误,我本来用的是String类型,但是输出的数据太多要用到List类型,但是String类型不能强制转换成List类型
关于时间的错误:java.sql.SQLException:无效的列索引 解决方法是
String con_inform_time = request.getParameter("con_inform_time");
con_inform_time = UtilValidate.isEmpty(con_inform_time) ? null : con_inform_time;
if (con_inform_time != null) {
where.append("AND TO_CHAR(INFOR_TIME,'YYYY-MM-DD') = '" + con_inform_time+"'");
queryParams.add(con_inform_time);
}
改成
String con_inform_time = request.getParameter("con_inform_time");
con_inform_time = UtilValidate.isEmpty(con_inform_time) ? null : con_inform_time;
if (con_inform_time != null) {
where.append("AND TO_CHAR(INFOR_TIME,'YYYY-MM-DD') = ?");
queryParams.add(con_inform_time);
}
java.sql.SQLException: ORA-01861: 文字与格式字符串不匹配
把TO_DATE(T.RECEIVE_TIME,'YYYY-MM-DD') >= ?改成
TO_CHAR(T.RECEIVE_TIME,'YYYY-MM-DD') >= ?
实现所用的代码是:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.txkj.business.account.model.Account"%>
<%@ include file="/common/include.jsp"%>
<script type="text/javascript">
function timeCheck(){
var t_start = $("input[name='start_time']", ${container}).val();
var t_end = $("input[name='end_time']", ${container}).val();
if(t_start>t_end && t_end.length !=0){
alertMsg.error('开始时间不能大于结束时间');
return false;
}
else{
return true;
}
}
function right_move()
{
var con_data=[];
for(var i=0;i<$("left_group").length;i++)
{
if($("left_group").options[i].selected)
con_data[con_data.length]=[$("left_group").options[i].value,$("left_group").options[i].text];
}
$("right_group").length=$("right_group").length;
for(var i=0;i<con_data.length;i++)
{
var con_fla=true;
for(var k=0;k<$("right_group").length;k++)
{
if(con_data[i][0]==$("right_group").options[k].value)
con_fla=false;
}
if(con_fla)
$("right_group").options[$("right_group").length]=new Option(con_data[i][1],con_data[i][0]);
}
}
function del_right()
{
var index_data=[];
for(var i=0;i<$("right_group").length;i++)
{
if($("right_group").options[i].selected)
index_data[index_data.length]=[i];
}
for(var i=index_data.length-1;i>=0;i--)
{
$("right_group").removeChild($("right_group").options[index_data[i]]);
}
}
function $(id){return document.getElementById(id);}
</script>
<div class="page">
<div class="pageHeader">
<form class="searchForm">
<div class="pageFormContent" layoutH="300">
<table>
<tr>充值统计</tr>
<tr height="10"></tr>
<tr>
<td>要统计的店铺</td>
<td width="20"></td>
<td>已经选择的店铺</td>
</tr>
<tr height="10"></tr>
<tr>
<td>
<select name="left_group" multiple="multiple" id="left_group"
style="width: 120px; height: 150px">
<option value="" selected>全部</option>
<c:forEach var="g" items="${lsit}">
<option value="${g['GROUP_CD']}">
${g['GROUP_CD']}
</option>
</c:forEach>
</select>
</td>
<td>
<input type="button" name="submit1" value="右移>>" onclick="right_move()" />
<br/>
<br/>
<input type="button" name="submit2" value="删除" onclick="del_right();" />
</td>
<td>
<select name="right_group" multiple="multiple" id="right_group"
style="width:120px; height:150px">
<!--<c:forEach var="g" items="${lsit}">
<option value="${g['GROUP_CD']}">
${g['GROUP_CD']}
</option>
</c:forEach>-->
</select>
</td>
</tr>
<tr height="20"></tr>
</table>
<div class="searchBar">
<table class="searchContent">
<tr>
<td>
查询周期:
</td>
<td>
<input name="con_recharge_start" type="text" class="date"
yearstart="-80" yearend="80" value="${date }"
readonly="readonly" />
</td>
<td>
-》
</td>
<td>
<input name="con_recharge_end" type="text" class="date"
yearstart="-80" yearend="80" value="${date }"
readonly="readonly" />
</td>
</tr>
</table>
</div>
<div class="subBar">
<ul>
<li>
<a class="button" target="pagination" befcall="timeCheck"><span>查询</span>
</a>
</li>
</ul>
</div>
</div>
</form>
<div>
总计充值N笔共计N元,N个客户代表有业务数据
</div>
</div>
<div class="pageContent">
<div class="tableList">
<table id="tablelist" class="list" width="100%">
<colgroup>
<col width="5%" />
<col width="10%" />
<col width="15%" />
</colgroup>
<thead>
<tr>
<td>
店铺名
</td>
<td>
业务笔数
</td>
<td>
业务金额
</td>
</tr>
</thead>
<tbody id="result"></tbody>
</table>
</div>
<div class="panelBar">
<div id="recharge_pagination" class="pagination" numPerPage="10"
pageNumShown="10" url="${ctx}/person/recharge!getShopRecharge.action"></div>
</div>
</div>
</div>
<!-- task data callback -->
<textarea id="function_pagination_callback" style="display: none">
function(data){
try{
// 附上模板
$("#result", ${container}).setTemplateElement("recharge_template");
// 给模板加载数据
$("#result", ${container}).processTemplate(data);
// css tables
$("#tablelist", ${container}).cssTable();
// init ui
$("#tablelist", ${container}).initUI();
} catch(e){}
}
</textarea>
<!-- 模板内容 -->
<textarea id="recharge_template" style="display: none">
{#foreach $T as record}
<tr>
<td>{$T.record.GROUP_CD}</td>
<td>{$T.record.COUNT}</td>
<td>{$T.record.SUM_MONEY}</td>
<td><td>
</td>
</tr>
{#/for}
</textarea>
出现的问题是:
解决方法是:function $(id){return document.getElementById(id);}
正确的实现方式是:bcims/webRoot/person/index.jsp里添加一个<script src="${ctx}/dwz/javascripts/dwz.combox.js" type="text/javascript"></script>
在bcims/webRoot/dwz/javascripts/dwz.combox.js里的dwz.combox.js替换成另外一个dwz.combox.js。内容不一样
原来的dwz.combox.js内容是:
/**
* @author Roger Wu
*/
(function($){
var allSelectBox = [];
$.extend($.fn, {
comboxSelect: function($box, options){
var op = $.extend({ selector: ">a" }, options);
var killAllBox = function(bid){
$.each(allSelectBox, function(i){
if (allSelectBox[i] != bid) {
if (!$("#" + allSelectBox[i])[0]) {
$("#op" + allSelectBox[i]).remove();
} else
$("#op" + allSelectBox[i]).css({
height: "",
width: ""
}).hide();
}
});
}
return this.each(function(){
var box = $(this);
var selector = $(op.selector, box);
box.append("<input type='hidden' name='" + selector.attr("name") + "' value='"+selector.attr("value")+"'/>")
.data("title", selector.text());
allSelectBox.push(box.attr("id"));
$(op.selector, box).click(function(){
var options = $("#op"+box.attr("id"));
if (options.is(":hidden")) {
if(options.height() > 300) {
options.css({height:"300px",overflow:"scroll"});
options.css("width",options.width() + 20);
}
var top = box.offset().top+box[0].offsetHeight-50;
if(top + options.height() > $(window).height() - 20) {
top = $(window).height() - 20 - options.height();
}
options.css({top:top,left:box.offset().left}).show();
killAllBox(box.attr("id"));
$(document).click(killAllBox);
} else {
$(document).unbind("click", killAllBox);
killAllBox();
}
return false;
});
$("#op"+box.attr("id")).find(">li").comboxOption(selector, box);
});
},
comboxOption: function(selector, box){
selector.text(box.data("title"));
$("input[name=" + selector.attr("name") + "]", box).attr("value", "");
return this.each(function(){
$(">a", this).click(function(){
var $this = $(this);
$this.parent().parent().find(".selected").removeClass("selected");
$this.addClass("selected");
selector.text($this.text());
var property = $("input[name=" + selector.attr("name") + "]", box);
if (property.val() != $this.attr("value")) {
var change = eval(selector.attr("change"));
if ($.isFunction(change)) {
var param = box.attr("param");
var rel = box.attr("rel");
var args = (!rel && param)?DWZ.jsonEval("{"+param + ":" + $this.attr("value")+"}"):$this.attr("value");
var options = change(args);
if(rel) {
var html = "";
for (var i = 0; i < options.length; i++) {
html += "<li><a href=\"#\" value=\"" + options[i][0] + "\">" + options[i][1] + "</a></li>";
}
var relObj = $(".combox").find(">div[name=" + box.attr("rel") + "]");
options = $("#op"+relObj.attr("id")).html(html);
$(">li", options).comboxOption($(">a", relObj), relObj);
}
}
}
property.attr("value", $this.attr("value"));
});
});
box.removeData("title");
},
combox:function(){
return this.each(function(){
var $this = $(this);
var name = $this.attr("name");
var value= $this.attr("value");
var label = $("option[value=" + value + "]",$this).text();
var ref = $this.attr("ref");
var param = $this.attr("param");
var cid = new Date().getTime();
var select = "<div class=\"combox\"><div id=\""+ cid +"\" class=\"select\"" + (ref?" rel=\"" + ref:"") + "\" name=\"" + name + "\"" + (param?" param=\"" + param:"") + "\">";
select += "<a href=\"#\" name=\"" + name +"\" value=\"" + value + "\" change=\"" + ($this.attr("change")?$this.attr("change"):"")+ "\">" + label +"</a></div></div>";
var options = "<ul class=\"comboxop\" id=\"op"+ cid +"\">";
$("option", $this).each(function(){
var option = $(this);
options +="<li><a class=\""+ (value==option[0].value?"selected":"") +"\" href=\"#\" value=\"" + option[0].value + "\">" + option[0].text + "</a></li>";
});
options +="</ul>";
$("body").append(options);
$this.after(select);
$("div.select", $this.next()).comboxSelect();
$this.remove();
});
}
});
})(jQuery);
替换的dwz.combox.js内容是:
/**
* @author Roger Wu
*/
(function($){
$.fn.extend({
combox:function(container){
return this.each(function(i){
var $this = $(this).removeClass("combox");
var name = $this.attr("name");
var selvalue= $this.attr("selvalue");
var ref = $this.attr("ref");
var refUrl = $this.attr("refUrl") || "";
if (selvalue && selvalue.length > 0){
$("option:selected",$this).attr("selected", false);
var arySelValue = selvalue.split(",");
for (var index=0; index<arySelValue.length; index++){
var each = arySelValue[index].trim();
$("option[value='" + each + "']",$this).attr("selected", true);
}
}
if (ref && refUrl) {
$this.bind("change", function(event){
var $ref = $("#"+ref);
if ($ref.size() == 0) return false;
$.ajax({
type:'GET', dataType:"json", url:refUrl.replaceTmById(container), cache: false,
data:{},
success: function(json){
if (!json) return;
var html = '';
$.each(json, function(i){
if (json[i]){
html += '<option value="'+json[i].VALUE +'">' + json[i].NAME + '</option>';
}
});
$ref.html(html);
},
error: DWZ.ajaxError
});
});
}
});
}
});
$.combobox = {
moveSelect: function(_src, _target){
var html = '';
_src.find('option:selected').each(function(){
if (_target.find('option[value="' + $(this).val() + '"]').size() == 0){
html += '<option value="'+ $(this).val() +'">' + $(this).text() + '</option>';
}
});
_target.append(html);
},
moveAll: function(_src, _target){
var html = '';
_src.find('option').each(function(){
if (_target.find('option[value="' + $(this).val() + '"]').size() == 0){
html += '<option value="'+ $(this).val() +'">' + $(this).text() + '</option>';
}
});
_target.append(html);
},
deleteSelect: function(_target){
_target.find('option:selected').remove();
},
deleteAll: function(_target){
_target.html('');
},
selectAll: function(_src){
$('option', _src).each(function(){
$(this).attr('selected', true);
});
},
unSelectAll: function(_src){
$('option', _src).each(function(){
$(this).attr('selected', false);
});
},
select: function(_src, values){
var ary = values.split(',');
for (var i=0; i<ary.length; i++){
$("option[value='" + ary[i].trim() + "']", _src).attr('selected', true);
}
},
add: function(_src, values, texts){
var html = '';
var aValue = values.split(',');
var aText = texts.split(',');
for (var i=0; i<aValue.length; i++){
var value = aValue[i].trim();
var text = aText[i].trim();
if (_src.find('option[value="' + value + '"]').size() == 0){
html += '<option value="'+ value +'">' + text + '</option>';
}
}
_src.append(html);
}
};
})(jQuery);
页面是这样写的:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.txkj.business.account.model.Account"%>
<%@ include file="/common/include.jsp"%>
<script type="text/javascript">
function timeCheck(){
var t_start = $("input[name='start_time']", ${container}).val();
var t_end = $("input[name='end_time']", ${container}).val();
if(t_start>t_end && t_end.length !=0){
alertMsg.error('开始时间不能大于结束时间');
return false;
}
else{
return true;
}
}
</script>
<div class="page">
<div class="pageHeader">
<form class="searchForm">
<div class="pageFormContent" layoutH="300">
<table>
<tr>充值统计</tr>
<tr height="10"></tr>
<tr>
<td>要统计的店铺</td>
<td width="20"></td>
<td>已经选择的店铺</td>
</tr>
<tr height="10"></tr>
<tr>
<td>
<select name="left_group" class="combox" multiple id="left_group"
ref="right_group"
style="width: 120px; height: 150px">
<option value="" selected>全部</option>
<c:forEach var="g" items="${lsit}">
<option value="${g['GROUP_CD']}">
${g['GROUP_CD']}
</option>
</c:forEach>
</select>
</td>
<td>
<div class="control">
<table width="100%" height="100%">
<tr>
<td align="center" valign="middle">
<a class="button"
onclick="$.combobox.moveSelect($('#left_group', ${container}), $('#right_group', ${container}));"><span> > </span>
</a>
<a class="button"
onclick="$.combobox.moveAll($('#left_group', ${container}), $('#right_group', ${container}));"><span>>></span>
</a>
<a class="button"
onclick="$.combobox.deleteSelect($('#right_group', ${container}));"><span> < </span>
</a>
<a class="button"
onclick="$.combobox.deleteAll($('#right_group', ${container}));"><span><<</span>
</a>
</td>
</tr>
</table>
</div>
</td>
<td>
<select name="right_group" multiple id="right_group"
style="width: 120px; height: 150px">
</select>
</td>
</tr>
<tr height="20"></tr>
</table>
<div class="searchBar">
<table class="searchContent">
<tr>
<td>
查询周期:
</td>
<td>
<input name="con_recharge_start" type="text" class="date"
yearstart="-80" yearend="80" value="${date }"
readonly="readonly" />
</td>
<td>
-》
</td>
<td>
<input name="con_recharge_end" type="text" class="date"
yearstart="-80" yearend="80" value="${date }"
readonly="readonly" />
</td>
</tr>
</table>
</div>
<div class="subBar">
<ul>
<li>
<a class="button" target="pagination" befcall="timeCheck"><span>查询</span>
</a>
</li>
</ul>
</div>
</div>
</form>
<div>
总计充值N笔共计N元,N个客户代表有业务数据
</div>
</div>
<div class="pageContent">
<div class="tableList">
<table id="tablelist" class="list" width="100%">
<colgroup>
<col width="5%" />
<col width="10%" />
<col width="15%" />
</colgroup>
<thead>
<tr>
<td>
店铺名
</td>
<td>
业务笔数
</td>
<td>
业务金额
</td>
</tr>
</thead>
<tbody id="result"></tbody>
</table>
</div>
<div class="panelBar">
<div id="recharge_pagination" class="pagination" numPerPage="10"
pageNumShown="10" url="${ctx}/person/recharge!getShopRecharge.action"></div>
</div>
</div>
</div>
<!-- task data callback -->
<textarea id="function_pagination_callback" style="display: none">
function(data){
try{
// 附上模板
$("#result", ${container}).setTemplateElement("recharge_template");
// 给模板加载数据
$("#result", ${container}).processTemplate(data);
// css tables
$("#tablelist", ${container}).cssTable();
// init ui
$("#tablelist", ${container}).initUI();
} catch(e){}
}
</textarea>
<!-- 模板内容 -->
<textarea id="recharge_template" style="display: none">
{#foreach $T as record}
<tr>
<td>{$T.record.GROUP_CD}</td>
<td>{$T.record.COUNT}</td>
<td>{$T.record.SUM_MONEY}</td>
<td><td>
</td>
</tr>
{#/for}
</textarea>
2013-07-08 09:16:50,717 [http-8080-3] DEBUG com.txkj.manager.query.PageIteratorSolver - [Framework]enter getPageIterator .. start= 0 count=10
2013-07-08 09:16:50,721 [http-8080-3] DEBUG com.txkj.manager.query.PageIteratorSolver - [Framework]enter getBlock ..
2013-07-08 09:16:50,726 [http-8080-3] DEBUG com.txkj.manager.query.block.BlockQueryJDBCTemp - [Framework]--> fetch the primary key collection, sql sentence: SELECT T.GROUP_CD, COUNT(1) COUNT, SUM(T1.PAY_MONEY) SUM_MONEY FROM B_M_GROUP T, PAY_AIR T1 WHERE 1=1 AND T.GROUP_CD = ? AND TO_CHAR(T1.RECEIVE_TIME,'YYYY-MM-DD') >= ? AND TO_CHAR(T1.RECEIVE_TIME,'YYYY-MM-DD') >= ? AND T.WORKER_ID = T1.WORKER_ID AND STATUS = 2 GROUP BY T.GROUP_CD+[Ljava.lang.String;@112bb2+2000-01-01+2013-07-08
2013-07-08 09:16:50,903 [http-8080-3] DEBUG com.txkj.manager.query.JdbcUtil - [JdonFramework]setQueryParams error java.sql.SQLException: 无效的列类型in parameter order=1 its value=[Ljava.lang.String;@112bb2
2013-07-08 09:16:50,912 [http-8080-3] DEBUG com.txkj.manager.query.JdbcUtil - [Framework] parameter 1 = [Ljava.lang.String;@112bb2
2013-07-08 09:16:50,921 [http-8080-3] DEBUG com.txkj.manager.query.JdbcUtil - [Framework] parameter 2 = 2000-01-01
2013-07-08 09:16:50,930 [http-8080-3] DEBUG com.txkj.manager.query.JdbcUtil - [Framework] parameter 3 = 2013-07-08
2013-07-08 09:16:50,947 [http-8080-3] ERROR com.txkj.manager.query.block.BlockQueryJDBCTemp - java.sql.SQLException: 索引中丢失 IN 或 OUT 参数:: 1
2013-07-08 09:16:50,952 [http-8080-3] DEBUG com.txkj.manager.query.PageIteratorSolver - [Framework]not found the block!
解决方法:遍历一下数组right_group,把right_group换成String类型,
具体代码如下:
String[] right_group = request.getParameterValues("right_group");
//right_group = UtilValidate.isEmpty(right_group null : right_group;
String right_groups ="";
for(int i = 0; i< right_group.length;i++)
{
right_groups +=right_group[i] + ",";
}
right_groups = "(" + right_groups.substring(0, right_groups.length()-1) + ")";
if(right_groups != null){
where.append(" AND T.GROUP_CD IN ? ");
queryParams.add(right_groups);
}