質問編集履歴
5
変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
mutterもしくはmutterListが取得できないのです
|
1
|
+
mutterもしくはmutterListが取得できないのです。コードの意味は理解したつもりなのですが、原因が不明です。コードを全て記載しました。どうかよろしくお願いします。
|
test
CHANGED
File without changes
|
4
説明文の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
+
doGet()でGetMutterListLogicのexecute()を呼び出し、
|
2
|
+
|
3
|
+
findAll()でデータベースから取得して、mutterListに代入して、return で返します。
|
4
|
+
|
5
|
+
mutterListを受け取った、doGetメソッドでrequest.setAttributeで、セットします。その後、main.jspにフォワードします。
|
6
|
+
|
7
|
+
main.jspでは、List<Mutter>mutterList=(List<Mutter>)request.getAttribute(“mutterList”); で、つぶやきリストを取得します。
|
8
|
+
|
9
|
+
そして、main.jspのactionで、methodには、postを指定して、
|
10
|
+
|
11
|
+
Main.javaのdoPostに飛び、new Mutter(text)で、mutterを作りpostMutterLogic.execute(mutter)で、excute()内で、dao.create(mutter)をして、MutterDAO.java内のcreate()内で、INSERT したsqlをpStmt.executeUpdate()でセットします。
|
12
|
+
|
13
|
+
その後、jspのHTMLコードの部分で<%for(Mutter mutter:mutterList){%>
|
14
|
+
|
15
|
+
<p><%=mutter.getText()%></p> によって出力します。
|
16
|
+
|
17
|
+
この時に使用される、getText()は、Mutter.javaにあるメソッドで、main.jspのimportで、<%@page import=“model.Mutter,java.util.List”%>のように、importしています。
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
1
23
|
mutterもしくはmutterListが取得できないのですが、なぜなのでしょうか?
|
2
24
|
|
3
25
|
|
3
コードの説明を追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,12 +1,6 @@
|
|
1
|
-
コードの内容としては、コメントしたTEXTをDATABASEに保存して、それを表示するだけなのですが、エラーがでて、main.jspに移ろうとした時にエラーとなります。
|
2
|
-
|
3
|
-
|
1
|
+
mutterもしくはmutterListが取得できないのですが、なぜなのでしょうか?
|
4
|
-
|
5
|
-
|
2
|
+
|
6
|
-
|
7
|
-
|
3
|
+
|
8
|
-
|
9
|
-
このようにしてみたりもしたのですが、直りませんでした。
|
10
4
|
|
11
5
|
どうぞよろしくお願いします。
|
12
6
|
|
2
エラーの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
```java
|
20
20
|
|
21
|
-
HTTP Status 500 -
|
21
|
+
HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/jsp/main.jsp at line 21
|
22
22
|
|
23
23
|
|
24
24
|
|
@@ -26,7 +26,7 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
message
|
29
|
+
message An exception occurred processing JSP page /WEB-INF/jsp/main.jsp at line 21
|
30
30
|
|
31
31
|
|
32
32
|
|
@@ -38,9 +38,31 @@
|
|
38
38
|
|
39
39
|
|
40
40
|
|
41
|
-
org.apache.jasper.JasperException:
|
41
|
+
org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/main.jsp at line 21
|
42
|
+
|
43
|
+
|
44
|
+
|
42
|
-
|
45
|
+
18: <input type="text"name="text">
|
46
|
+
|
47
|
+
19: <input type="submit" value="つぶやく">
|
48
|
+
|
49
|
+
20: </form>
|
50
|
+
|
51
|
+
21: <% for(Mutter mutter:mutterList){%>
|
52
|
+
|
53
|
+
22: <p><%=mutter.getText() %></p>
|
54
|
+
|
55
|
+
23: <%} %>
|
56
|
+
|
57
|
+
24: </body>
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
Stacktrace:
|
64
|
+
|
43
|
-
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:55
|
65
|
+
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:575)
|
44
66
|
|
45
67
|
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:477)
|
46
68
|
|
1
誤字修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -240,7 +240,7 @@
|
|
240
240
|
|
241
241
|
<%
|
242
242
|
|
243
|
-
//
|
243
|
+
//リクエストスコープに保存されたつぶやきリストを取得
|
244
244
|
|
245
245
|
List<Mutter>mutterList=(List<Mutter>)request.getAttribute("mutterList");
|
246
246
|
|