我想回显在请求中选择的缓存操作,以便它显示在浏览器上。我很少有 JSP 经验。我怎样才能让操作的价值出现?
JSP:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<body>
<h1>Cache Operation Results - ${operation}</h1>
<ul>
<c:forEach items="${results}" var="nextObject">
<pre>${nextObject.toString()}</pre>
</c:forEach>
</ul>
</body>
</html>
控制器片段:
@RequestMapping(value = "/objectcache", method = RequestMethod.GET)
public ModelAndView objectCache(@RequestParam("operation") String operation, HttpServletRequest req) {
List<String> cacheReturnValue = new ArrayList<String>();
ModelAndView mav = new ModelAndView("/utils/objectCache", "results", cacheReturnValue);
if (operation.equalsIgnoreCase("reload")) {
cacheReturnValue = this.reloadCache();
}
mav.addObject("operation", operation);
return new ModelAndView("/utils/objectCache", "results", cacheReturnValue);
}