我正在尝试使用spring框架在java中开发一个网络监控应用程序。它列出了网络中的所有资源。通过单击其中一个资源 ID,页面必须重定向到一个新页面,该页面显示该资源的所有详细信息。这样,下一个页面会根据我们点击的资源 id 更改为新内容。现在我只是通过在控制器中映射页面来连接下一页,但是页面是空的,即值没有正确传递给控制器。
我的控制器:
@RequestMapping(value = "/deviceInformation", method = RequestMethod.GET)
public String deviceinfo(ModelMap model, HttpServletRequest request) {
List<NetworkInterface> list = inventoryService.getNetworkInterfaces("");
List<NetworkService> list2 = inventoryService.getNetworkServices("ipResource.discoveredName");
List<Equipment> list3 = inventoryService.getEquipments("resourceId");
List<Processor> list4 = inventoryService.getProcessors("hostId");
List<SoftwareRunning> list5 = inventoryService.getSoftwaresRunning("hostId");
List<StorageDisk> list6 = inventoryService.getStorageDisks("hostId");
List<StorageMemory> list7 = inventoryService.getStorageMemories("hostId");
model.addAttribute("INlist", list);
model.addAttribute("Serlist", list2);
model.addAttribute("Eqlist", list3);
model.addAttribute("Prolist", list4);
model.addAttribute("SRlist", list5);
model.addAttribute("Storlist", list6);
model.addAttribute("StoMry", list7);
return "inventory/deviceInformation";
}
@RequestMapping(value = "/interfaceList/{ipResource.discoveredName}", method = RequestMethod.POST)
public ModelAndView getInterface(@PathVariable String resourceId, HttpServletRequest request,
HttpServletResponse response) {
System.out.println("Got request param: " + resourceId);
List<NetworkInterface> list = inventoryService.getNetworkInterfaces("resID");
List<NetworkService> list2 = inventoryService.getNetworkServices("ipResource.discoveredName");
List<Equipment> list3 = inventoryService.getEquipments("ipResource.discoveredName");
List<Processor> list4 = inventoryService.getProcessors("hostId");
List<SoftwareRunning> list5 = inventoryService.getSoftwaresRunning("hostId");
List<StorageDisk> list6 = inventoryService.getStorageDisks("hostId");
List<StorageMemory> list7 = inventoryService.getStorageMemories("hostId");
ModelAndView modelAndView = new ModelAndView("/inventory/deviceInformation");
modelAndView.addObject("INlist", list);
modelAndView.addObject("Serlist", list2);
modelAndView.addObject("Eqlist", list3);
modelAndView.addObject("Prolist", list4);
modelAndView.addObject("SRlist", list5);
modelAndView.addObject("Storlist", list6);
modelAndView.addObject("StoMry", list7);
return modelAndView;
}