我正在编写一个 JSP 页面,它从 servlet 检索变量并将它们输出给用户,我当前的代码工作如下:
String uploadStatus = (String) request.getAttribute("uploadStatus");
String readStatus = (String) request.getAttribute("readStatus");
String saveStatus = (String) request.getAttribute("saveStatus");
String completeStatus = (String) request.getAttribute("completeStatus");
String applicationName = (String) request.getAttribute("applicationName");
String buildAndroid = (String) request.getAttribute("buildAndroid");
String buildWindows = (String) request.getAttribute("buildWindows");
String buildiOS = (String) request.getAttribute("buildiOS");
String uploadCompleteStatus = (String) request.getAttribute("uploadCompleteStatus");
String startBuild = (String) request.getAttribute("startBuild");
String finishBuild = (String) request.getAttribute("finishBuild");
out.println(uploadStatus + "<br>");
out.println(readStatus + "<br>");
out.println(saveStatus + "<br>");
out.println(applicationName + "<br>");
out.println(buildAndroid + "<br>");
out.println(buildWindows + "<br>");
out.println(buildiOS + "<br>");
out.println(uploadCompleteStatus + "<br>");
out.println(startBuild + "<br>");
out.println(finishBuild + "<br>");
它工作得很好,但代码很长而且不是很可扩展。我想知道他们是否是一种在 JSP 中使用 for 循环和可能的通配符更简单的方法。有人有什么想法吗?
谢谢