- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
遇到一个问题,我返回三个 json 对象。无论如何,我想做的就是作为一个 JSON 对象返回。与我下面的结果类似。所以,我试图展示我的 Controller - 我相信我的 Controller 返回 3 个对象而不是 1 个。感谢您的帮助。
这是我的代码:
我尝试这样做:
@RequestMapping(value = "all", method = RequestMethod.GET)
public @ResponseBody
MyAutoComplete getMoney(@RequestParam(value = "myautocomplete") String myautocompleteValue) {
List<MyAutoComplete> list = myautoCompleteService.gettingMoney(myautocompleteValue);
return merge(list);
}
MyAutoComplete merge(List<MyAutoComplete> list){
MyAutoComplete accountacy = list.get(0);
for (int i = 1; i < list.size(); i++) {
MyAutoComplete myautoComplete = list.get(i);
if (myautoComplete.getTimeAnnual() != null) {
accountacy.setTimeAnnual((autoComplete.getTimeAnnual(());
}
if (autoComplete.getTimeBiweekly() != null) {
accountacy.setTimeBiweekly(autoComplete.getTimeBiweekly());
}
if (autoComplete.getTimeHourly() != null) {
accountacy.setTimeHourly(autoComplete.getTimeHourly());
}
}
return accountacy;
}
最佳答案
如果无法更改存储库端的查询,可以将列表中的对象合并到 Controller 中的单个对象
public @ResponseBody
LIst<AutoComplete> getSalary(@RequestParam(value = "autocomplete") String autocompleteValue) {
List<AutoComplete> list = autoCompleteService.retrieveSalary(autocompleteValue);
return Arrays.asList(merge(list));
}
AutoComplete merge(List<AutoComplete> list){
AutoComplete acc = list.get(0);
for (int i = 1; i < list.size(); i++) {
AutoComplete autoComplete = list.get(i);
if (autoComplete.getAnnual() != null) {
acc.setAnnual(autoComplete.getAnnual());
}
if (autoComplete.getBiweekly() != null) {
acc.setBiweekly(autoComplete.getBiweekly());
}
if (autoComplete.getHourly() != null) {
acc.setHourly(autoComplete.getHourly());
}
}
return acc;
}
关于java - 三个物体合而为一?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56910637/
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题吗? Update the question所以它是on-topic用于堆栈溢出。 关闭 10 年前。 Improve thi
我正在开发一个 Android 应用程序 - 学校时间表。我应该在学校制定 50 份表格的时间表。主屏幕 - 带有按钮的 Activity ,可以将您转移到表单的时间表。 1 个表单 = 1 个 Ta
请原谅,因为我想答案很简单,尽管我发誓我进行了研究但一无所获。 我想设置一个超链接的样式,而不是用这种方式: #div a:link {color: #fff; text-decoration: un
在我们公司,我们有许多不同的模块构建为单独的 war 。每个客户都可以挑选他想购买的模块。由于所有模块共享相同的 session 、安全上下文等,因此将它们合并到一个 war 中是有意义的。 是否可以
这是我一直用于在当前目录中的 php 文件中查找匹配项 (queryString) 的命令,grep 不区分大小写,并在行中显示匹配结果: 找 。 -iname "*php"-exec grep -i
我有下面的代码可以工作,但是如果有办法的话我怎样才能让它更短。我会详细解释一下。 我将这三个声明为全局: private Map pictureinfo = new HashMap(); privat
我有一个 wordpress 模板,其中包含一组来自 addthis 的分享按钮 ">
我看到一些网站使用 CSS 来更改页面而不使用 javascript,并且它们使用主题标签来记住用户正在查看的页面。 输入 url example.com/#page1 的示例将显示 page1 等。
不幸的是,我无法弄清楚我需要在这里做什么。首先,这是我可爱的测试站点:http://elijahhoffman.com/testsite/ 现在说说我想要完成的事情。我有一个带有包含图像的 div(幻
我正在尝试将 Twilio IP-Messaging 集成到也使用 Twilio Conversations(视频) 的应用程序中。但是,根据更改日志,IP 消息传递 SDK 使用“common-an
我有一个应用程序,许多用户在不同级别的权限上可以“查看/选择”。 用户形成一个层次结构。 Level1--> Level2--Level3 等等 Level1用户可能有很多Level2用户,类似Lev
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我是一名优秀的程序员,十分优秀!