按年份查询结果
digli 2011-08-16 03:13:39 这是在Action里面写的查询MySql数据库的结果,在jsp页面上显示出来的。
private List<Finance> getFinanceList(HttpServletRequest request)throws Exception{
ICommonService commonService = this.getCommonService();
Finance finance = new Finance();
List<CAgreementAmount> amountList = this.getCommonService().getObjectList("from CAgreementAmount");
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Double[] d7eto= new Double[13];// 有12个月 ,第十三个月是存放十二个月的总和
CAgreementAmount caa =new CAgreementAmount();
for(CAgreementAmount aa : amountList) {
String date = aa.getPaymentDeadline();
String[] D = date.split("-");
String year = D[0];
String month = D[1];
String day = D[2];
CAgreement a = aa.getCAgreement();
List<CAgreementProgram> aplist = this.getCommonService().getObjectList("from CAgreementProgram c where c.id.agreementId=" + a.getId());
for(CAgreementProgram ap : aplist) {
CProgram p = (CProgram)this.getCommonService().getObj("from CProgram c where c.id=" + ap.getId().getProgramId());
CProgramType pt = p.getCProgramtype();
if(year.equals("2011")) {
if(pt.getName().equals("ETOM") || pt.getName().equals("ETOV")){
int x = format.parse(aa.getPaymentDeadline()).getMonth();
if(d7eto[x]==null){
d7eto[x]=0.0;
}
d7eto[x]=d7eto[x]+aa.getPaidamount(); // 存放每个月的结果
if(d7eto[12]==null){
d7eto[12]=0.0;
}
d7eto[12]=d7eto[12]+aa.getPaidamount();// 存放十二个月的总和
}
}
}
finance.setEtomainBusinessIncome(d7eto);
List list=new ArrayList();
list.add(finance);
request.setAttribute("list", list);
return list;
}
}
jsp 页面上:
<body>
<form action="" method="post">
<div>
<input type="text" class="text_time" name="fromTime" value=" " />
<input type="button" class="button_01" value="Create" onclick="gogo();"/>
<input type="button" class="button_01" value="Excel" onclick="outExcel();"/>
</div>
<table class="table_01" id="table_01">
<tr bgcolor="#99CC00">
<td bgcolor="#FEFEFE"> </td>
<td>科目</td>
<td>一月</td>
<td>二月</td>
<td>三月</td>
<td>四月</td>
<td>五月</td>
<td>六月</td>
<td>七月</td>
<td>八月</td>
<td>九月</td>
<td>十月</td>
<td>十一月</td>
<td>十二月</td>
<td>Total</td>
</tr>
<tr>
<td >ETO</td>
td>主营业务收入</td>
<c:forEach items="${list}" var="finance" >
<td><input type="text" value="${finance.etomainBusinessIncome[0]}" id="1SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[1]}" id="2SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[2]}" id="3SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[3]}" id="4SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[4]}" id="5SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[5]}" id="6SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[6]}" id="7SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[7]}" id="8SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[8]}" id="9SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[9]}" id="10SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[10]}"id="11SR" size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[11]}" id="12SR"size=2 style="border:0px;"/></td>
<td><input type="text" value="${finance.etomainBusinessIncome[12]}" id="13SR"size=2 style="border:0px;"/></td>
</c:forEach>
</tr>
我现在是想实现在jsp页面上,输入年份(如输入2011 点击 Create 按钮 就把2011 年的 ETO主营业务收入 查询出来 ,
输入2010 点击 Create 按钮 就把2010 年的 ETO主营业务收入 查询出来 ).在Action 里面还要做哪些修改,jsp页面上怎么写。
小弟现在卡在这里了,还望会的人 不吝赐教 不胜感激。