質問編集履歴
2
コードを変更いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -108,11 +108,11 @@
|
|
108
108
|
|
109
109
|
if (list != null) {
|
110
110
|
|
111
|
-
bookName =
|
111
|
+
bookName = *******;
|
112
112
|
|
113
|
-
detail =
|
113
|
+
detail = *******;
|
114
114
|
|
115
|
-
author =
|
115
|
+
author = *******;
|
116
116
|
|
117
117
|
request.setAttribute("booktitle", bookName);
|
118
118
|
|
1
コードを見やすく修正いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,12 +1,94 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
|
-
|
3
|
-
|
4
2
|
|
5
3
|
listの値をどのように変数に格納したらいいか教えてください。
|
6
4
|
|
7
5
|
以下if文で、bookNameにlist のgetBooktitleを格納したいです。
|
8
6
|
|
9
7
|
よろしくお願いいたします。
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
```Serblet
|
12
|
+
|
13
|
+
package book;
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
import java.io.IOException;
|
18
|
+
|
19
|
+
import java.util.ArrayList;
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
import javax.servlet.RequestDispatcher;
|
24
|
+
|
25
|
+
import javax.servlet.ServletException;
|
26
|
+
|
27
|
+
import javax.servlet.annotation.WebServlet;
|
28
|
+
|
29
|
+
import javax.servlet.http.HttpServlet;
|
30
|
+
|
31
|
+
import javax.servlet.http.HttpServletRequest;
|
32
|
+
|
33
|
+
import javax.servlet.http.HttpServletResponse;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
import dao.BookDao;
|
38
|
+
|
39
|
+
import dba.DBManager;
|
40
|
+
|
41
|
+
import dto.BookDto;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
/**
|
46
|
+
|
47
|
+
* Servlet implementation class BookDetailServlet
|
48
|
+
|
49
|
+
*/
|
50
|
+
|
51
|
+
@WebServlet(description = "一覧画面にて作品詳細ボタン押下時に受け取るServletクラス", urlPatterns = { "/BookDetailServlet" })
|
52
|
+
|
53
|
+
public class BookDetailServlet extends HttpServlet {
|
54
|
+
|
55
|
+
private static final long serialVersionUID = 1L;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
/**
|
60
|
+
|
61
|
+
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
|
62
|
+
|
63
|
+
* response)
|
64
|
+
|
65
|
+
*/
|
66
|
+
|
67
|
+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
|
68
|
+
|
69
|
+
throws ServletException, IOException {
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
int id = 0;
|
74
|
+
|
75
|
+
String bookName = null;
|
76
|
+
|
77
|
+
String detail = null;
|
78
|
+
|
79
|
+
String author = null;
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
BookDto book = new BookDto(id, bookName, detail, author);
|
84
|
+
|
85
|
+
String idAsString = request.getParameter("id");
|
86
|
+
|
87
|
+
id = Integer.parseInt(idAsString);
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
DBManager db = new DBManager();
|
10
92
|
|
11
93
|
|
12
94
|
|
@@ -26,11 +108,11 @@
|
|
26
108
|
|
27
109
|
if (list != null) {
|
28
110
|
|
29
|
-
bookName =
|
111
|
+
bookName = book.getBooktitle();
|
30
112
|
|
31
|
-
detail =
|
113
|
+
detail = book.getBooktext();
|
32
114
|
|
33
|
-
author =
|
115
|
+
author = book.getAuthor();
|
34
116
|
|
35
117
|
request.setAttribute("booktitle", bookName);
|
36
118
|
|
@@ -49,3 +131,13 @@
|
|
49
131
|
e.printStackTrace();
|
50
132
|
|
51
133
|
}
|
134
|
+
|
135
|
+
}
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
```
|