プロジェクト ページから移動して、現在のプロジェクトのタスクを表示します。
選択したプロジェクトのタスク ページにリダイレクトする必要があります。ok url にリダイレクトされますが、ページが表示されません。それは白いページを示しています:
URL は正しく、パラメーターは正しく渡されます。
ここに抜粋されていprojectTable.jsp
ます:
<form action="${pageContext.request.contextPath}/manager/projectstable" method="post" id="projectstable-form">
<div class="row">
<div class="table-responsive tile col-md-10 col-sm-12 col-xs-12 col-md-offset-1">
<table class="table table-striped table-hover">
<!-- Table -->
<thead>
<tr>
<th></th>
<th>#</th>
<th><fmt:message key="project.name" /></th>
<th><fmt:message key="project.description" /></th>
<th><fmt:message key="project.notes"/></th>
<th><fmt:message key="project.tasks"/></th>
</tr>
</thead>
<tbody>
<c:forEach var="project" items="${requestScope.projects}">
<tr>
<td>
<label class="checkbox" for="checkbox${project.id}">
<input type="checkbox" name="checkedProjects" value="${project.id}"
id="checkbox${project.id}" data-toggle="checkbox">
</label>
</td>
<td>${project.id}</td>
<td>${project.projectName}</td>
<td>${project.description}</td>
<td>${project.notes}</td>
<td><a href="${pageContext.request.contextPath}/manager/taskstable?project_id=${project.id}"
class="btn btn-info btn-xs"><fmt:message key="project.see.tasks"/></a>
</td>
ブラウザでの表示:
移動はリンクボタン - として実装されていますSee tasks
。
TasksTableServletのスニペットは次のとおりです。
@WebServlet("/manager/taskstable")
@MultipartConfig
public class TasksTableServlet extends HttpServlet {
private static Logger log = Logger.getLogger(AddTaskServlet.class);
private TaskService taskService;
private List<Task> tasks;
private static final String DATE_FORMAT = "MM/dd/yyyy";
public static final String ATTRIBUTE_TO_MODEL = "tasksList";
public static final String PAGE_OK = "/pages/manager/tasksTable.jsp";
public static final String PAGE_ERROR_URL = "error";
@Override
public void init() throws ServletException {
taskService = new TaskService();
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
if (request.getParameter("project_id") != null) {
System.out.println("ID: " + request.getParameter("project_id"));
updateTable(request);
if (!tasks.isEmpty()) {
request.setAttribute(ATTRIBUTE_TO_MODEL, tasks);
request.getRequestDispatcher(PAGE_OK);
return;
}
}
} catch (Exception e) {
log.error(e);
}
response.sendRedirect(PAGE_ERROR_URL);
}
private void updateTable(HttpServletRequest request) {
try {
int id = Integer.parseInt(request.getParameter("project_id"));
tasks = taskService.getByProjectId(id);
} catch (DAOException e) {
log.error(e);
}
}
このページが表示されない理由がわかりませんでした。私の考えでは、うまくいくはずです。
この問題を解決するにはどうすればよいですか?