私が作成した小さなプログラムのフロント エンドを表示するサーブレットを作成しています。このプログラムには、文字列ビルダーに配置する LinkedList 呼び出し実行キューがあります。
public String getJobsForPrint() {
Iterator<JobRequest> it = ExecutionQueue.iterator();
StringBuilder result = new StringBuilder();
String NEW_LINE = System.getProperty("line.separator");
while (it.hasNext()) {
JobRequest temp = it.next();
result.append(this.getClass().getName()).append(" Object {").append(NEW_LINE);
result.append(" User ID: ").append(temp.getUserID());
result.append(" Start Date: ").append(temp.getStartDate());
result.append(" End Date: ").append(temp.getEndDate());
result.append(" Deadline Date: ").append(temp.getDeadDate());
result.append(" Department: ").append(temp.getDepartment());
result.append(" Project Name: ").append(temp.getProjectName());
result.append(" Project Application: ").append(temp.getProjectApplication());
result.append(" Priority: ").append(temp.getPriority());
result.append(" Cores: ").append(temp.getCores());
result.append(" Disk Space: ").append(temp.getDiskSpace());
result.append(" Analysis: ").append(temp.getAnaylsis()).append(NEW_LINE);
result.append("}");
}
return result.toString();
私のサーブレット側では、次の方法で文字列を呼び出します。
protected void processExecutionQueue(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Execution Queue</title>");
out.println("</head>");
out.println("<body>");
out.println("<div>");
out.println("<div style='position:absolute; top:20px; right: 20px;'><a href='/ProjectAndBackend/index.jsp'>LOGOUT</a></div>");
out.println("</div>");
out.println("<p>Queue:</p>");
out.println("Execution Queue:" + SystemServlet.getScheduler().getJobsForPrint());
out.println("</body>");
out.println("</html>");
}
そのため、リンクリストから取得したすべてのデータを使用して、文字列を次々に表示します。私はウェブページ側で、そのデータを取得してテーブルに配置できるようにしたいと考えています。これにより、ウェブページに文字列が投げ込まれるだけでなく、見栄えが良くなります。
特定の側面で文字列の特定の要素を表示するために html を実装するにはどうすればよいですか?したがって、以下の例では、ヘッダーがあり、データが文字列から要素を取得し、イテレータからのすべてのデータが表示されるまでそれを書き続けます。
<table border="1">
<tr>
<th>User ID</th>
<th>Start Date</th>
</tr>
<tr>
<td>User ID DATA</td>
<td>Start Date DATA</td>
</tr>
または、現在の検索で何も見つからないため、誰かが私に例を教えてくれる場合。