当用户从下拉菜单中单击一个项目时,Web 视图应该会弹出多个 HTML 组件。这是我需要在视图中添加的内容:
1. A JSON object which include a large array of data for autocomplete dropdown menu
2. Some other pojo collections for regular html component values.
如果我使用以下 Spring MVC 控制器方法:
@RequestMapping(value="{name}", method = RequestMethod.GET)
public @ResponseBody Shop getShopInJSON(@PathVariable String hotelName) {
List<Hotel> hotels = getHotelByNameLike(hotelName);
return hotels;
}
并将其他 pojo 对象添加为ModelAttribute
@ModelAttribute("someName")
public Collection<SomeObject> populateObject() {
return Object.getAllObjects();
}
以下是关于上述计划的一些问题:
1. There are two solution regarding `autocomplete`
a. Each time user type in inputbox, generate a new `Like`query to getch similar results
b. Use JSON to load all data to the view and let javascript to filter out the data in the memory.
Plan be is preferred, but how can above code implement plan b?
2. Above code fails to mention `view` name which responds to the request from menu event.
3. Can above solution work out to bring both JSON object and POJO object to the same view?