- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面有一些代码,用于查询数据库并将数据添加到列表中,
Query q= session.createQuery("select tally_receipt_prefix, tally_receipt_no, tally_head, tally_amount from Tally_table where tally_system_date='"+fmtd_date+"' and tally_dbcr_indicator='DB' and tally_mode='Ca' order by tally_head,tally_receipt_prefix,tally_receipt_no");
payincash = new ArrayList();
for(Iterator it=q.iterate(); it.hasNext(); )
{
Object[] row= (Object[]) it.next();
payincash.add((String)row[0]);
payincash.add((String)row[1]);
payincash.add((String)row[2]);
payincash.add((String)row[3]);
}
System.out.println("cash list in dao: "+payincash);
返回的列表类似于 [prefix1, no1, head1, amt1, prefix2, no2, head2, amt2,]。我正在尝试在 jsp 中按以下行制作收据
前缀1/no1 amt1
前缀2/no2 amt 2
<小时/>前缀3/no3 amt3
看起来我想按收据 - jsp 文件中的头列对所有记录进行分组。我该怎么办?任何帮助都非常感激。请原谅我的英语。
编辑:这是我尝试过的,
查询q= session.createQuery("从Tally_table中选择tally_receipt_prefix、tally_receipt_no、tally_head、tally_amount,其中tally_system_date='"+fmtd_date+"'和tally_dbcr_indicator='DB'和tally_mode='Ca'按tally_head、tally_receipt_prefix、tally_receipt_no排序"); System.out.println("查询"+q);
List heads=new ArrayList();
for(Iterator it=q.iterate(); it.hasNext(); )
{
Object[] row= (Object[]) it.next();
payincash1=new LinkedHashMap<String, List>();
heads.add((String)row[2]);
List tails = null;
tails=new ArrayList();
tails.add((String)row[0]);
tails.add((String)row[1]);
tails.add((String)row[3]);
System.out.println("heads in dao from iter 1: "+heads);
System.out.println("tails in dao from iter1 on: "+tails);
if(heads.contains((String)row[2])) // for head in temp list
{
System.out.println("in first if");
if(payincash1.containsKey((String)row[2]))
{
System.out.println("map if repeat: "+payincash1);
payincash1.put((String)row[2],tails);
}
}
else
{
System.out.println("map if not repeat: "+payincash1);
payincash1.put((String)row[2], tails);
}
}
最佳答案
收据的头栏存储在哪里?在哪一栏?
以我的愚见,它也应该存储在数据库中。
假设头信息保存在数据库的“head”列中,因此您应该通过添加以下内容来更改查询:
order by head
最后。
之后,您应该迭代结果,并且可能将信息保存在如下所示的数据结构中:
Map<String,List<ReceiptInformation> map = new HashMap<>(); //using JDK7 syntax here
映射中的键应该是每次迭代中“head”的值。映射中的值应该是保存 ReceiptInfo 对象的 ArrayList(或任何其他实现 List 的类)。
ReceiptInfoObject 保存每条记录的所有其余值。
然后,您可以迭代 map.keySet() 集合,并为每个键打印头部,然后使用内部循环打印收据。
根据提出问题的用户的请求进行编辑:
为了添加新条目(即新的 RecepitInformation 对象到 map ),应该执行:
List<RecepitInformation> listForHead = map.get(headValue);
if (listForHead == null) {
listForHead = new ArrayList<ReceiptInformation>();
map.put(headValue,listForHead);
}
listForHead.add(recepitInformation);
像往常一样,我没有编译它,但我认为它应该可以工作
关于java - 按元素对列表项进行分组以在 jsp 收据中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12147997/
我一直在尝试学习Grails,但是我遇到了以下问题。我已经创建了四个域类(Receipts,Items,类别和所有者),并且为每个域类(ReceiptsController,ItemsControll
我正在构建一个销售点应用程序,我想打印一张收据。问题是我使用的打印机无法打印纯文本的任何图形,我在 javafx 中只能找到使用 Print API 打印节点或使用像 jasper 这样都包含图形的报
我正在 Swift 3.0 应用程序中实现应用程序内购买,因此我需要获取应用程序收据以根据 iTunes 商店对其进行验证。这是我获得收据的方式: func getReceipt() -> Data?
我想在我的数据库中保存非消耗品的 IAP 收据。我们有一个用于 IAP 恢复的两步下载机制。 使用 StoreKit 机制检索所有交易(包括收据)。 从所有收据(即这些收据背后的产品)列表中选择稍后要
我想验证 iOS 收据。 我想我会向 App Store 验证服务器发送收据(https://sandbox.itunes.apple.com/verifyReceipt 或 https://buy.
我需要打印具有相同产品数量等的销售订单的 POS 收据 在销售订单中,我创建了一个按钮“打印 POS 收据”。使用此按钮,我想触发一种方法,该方法打印出带有销售订单行的收据。 所以我需要找到创建 PO
我们现在有一个正在生产中的应用程序,它会将 IAP 收据发送到我们的服务器,这些收据显然太短,而且我们的服务器没有经过 apple 的验证。 Apple 正确验证的长收据长度为 3192。短收据长度均
我正在构建一个 iOS 应用程序,它提供我们网站已经提供的服务。这是一项基于订阅的服务,订阅后所有功能都会启用。为了让人们在应用程序上注册定期付款,我似乎必须通过 Apple 的应用程序内购买 API
我需要一种方法来捕获笔记本中打印的所有内容。 为什么? 我有一个 PHP 系统,有时我需要打印(php_printer) 一些发票,但这会花费很多纸张。 打印在后台发送,没有任何弹出窗口供用户确认。
我对此有点困惑。所以关注this approach我得到了包含一堆解密字段的 json。其中 original_purchase_date。 我需要的是跟踪在这个新版本免费之前是否购买了应用程序,我认
首先,我说的不是调用https://buy.itunes.apple.com/verifyReceipt/ ,相反,我要问的是如何验证来 self 们的一位用户的 iTuneStore 收据。 我们的
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 5 年前。
所以我要建立一个在线商店,我想向客户发送包含收据的订单确认。我搜索了一下,但我还没有设法创建任何东西。 这是我发现并尝试使用的东西,但没有成功创建任何东西。 所以 ajax 调用会将 cartCon
所以我要建立一个在线商店,我想向客户发送包含收据的订单确认。我搜索了一下,但我还没有设法创建任何东西。 这是我发现并尝试使用的东西,但没有成功创建任何东西。 所以 ajax 调用会将 cartCon
我正在尝试实现自动续订订阅。我的应用程序可以在不同的设备(Android、Web)上使用,因此我需要实现状态轮询技术,以便在 App Store 设法续订过期订阅时确认我的服务器。收据正在我的服务器上
我正在尝试验证来自 C++ 服务器的 iphone 收据(我有使用 base64 加密的收据,我正在根据苹果文档编写一个 json 对象,然后我打开一个到沙箱的套接字并发送一个 POST请求)。 服务
首先,这个问题与 iOS7+ 收据有关,因此所有关于 latest_receipt 和 latest_receipt_info 的问题/答案都不适用(因为它们已被弃用并且正在离开)。似乎关于在 SO
谁能告诉我如何使用 Exchange Web 服务 API 获取电子邮件正文、收据、发件人、抄送信息?我只知道如何获取主题。 ExchangeService service = new Exchang
有关服务器到服务器通知的 Apple 文档没有指定 cancellation_date 字段中的数据格式。我正在尝试为我的通知处理程序设置一些单元测试,但我不确定要将哪些数据放入我的模拟响应中。 我假
我正在尝试使用 Citizen CT-S651 热敏打印机从网络浏览器打印 HTML/CSS 媒体格式的收据。我们已经能够正确格式化收据,但问题是在打印收据后,打印机继续吐纸而不是在内容的末尾切割。
我是一名优秀的程序员,十分优秀!