質問編集履歴
1
プログラムを乗せた
test
CHANGED
File without changes
|
test
CHANGED
@@ -11,3 +11,237 @@
|
|
11
11
|
Test02.javaではidの有無により処理を分岐しています
|
12
12
|
|
13
13
|
idがある場合はtest02.jspでそのIDに対する中身を表示できているのですがIDがない場合は何も表示されなくて困ってます
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
### 該当のソースコード
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
```test01jsp
|
22
|
+
|
23
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
24
|
+
|
25
|
+
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
26
|
+
|
27
|
+
<!DOCTYPE html>
|
28
|
+
|
29
|
+
<html>
|
30
|
+
|
31
|
+
<head>
|
32
|
+
|
33
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
34
|
+
|
35
|
+
<script type="text/javascript" src="../js/dialog.js" charset="UTF-8">
|
36
|
+
|
37
|
+
</script>
|
38
|
+
|
39
|
+
<title>test</title>
|
40
|
+
|
41
|
+
<script type="text/javascript">
|
42
|
+
|
43
|
+
<!--
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
function deleteEmp(info.id) {
|
48
|
+
|
49
|
+
if(window.confirm('OK')){
|
50
|
+
|
51
|
+
location.href = "./Delete?id=" + id;
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
// -->
|
60
|
+
|
61
|
+
</script>
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
</head>
|
66
|
+
|
67
|
+
<body>
|
68
|
+
|
69
|
+
<a href="./Register">登録</a><br>
|
70
|
+
|
71
|
+
<h1>一覧</h1>
|
72
|
+
|
73
|
+
<table border="1">
|
74
|
+
|
75
|
+
<tr><th>No</th><th>会社名</th><th>社員名</th><th>社員ID</th><th>性別</th><th>勤務形態</th><th>詳細</th><th>削除</th></tr>
|
76
|
+
|
77
|
+
<c:forEach var="info" items="${en}" >
|
78
|
+
|
79
|
+
<tr>
|
80
|
+
|
81
|
+
<td><c:out value="${info.id}" /></td>
|
82
|
+
|
83
|
+
<td><a href="./Test02?ed=${info.id}">中身</a></td>
|
84
|
+
|
85
|
+
<td><p><a onClick="deleteEmp('${info.id}')">削除</a></p></td>
|
86
|
+
|
87
|
+
</tr>
|
88
|
+
|
89
|
+
</c:forEach>
|
90
|
+
|
91
|
+
</table>
|
92
|
+
|
93
|
+
</body>
|
94
|
+
|
95
|
+
</html>
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
```test02jsp
|
102
|
+
|
103
|
+
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
104
|
+
|
105
|
+
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
106
|
+
|
107
|
+
<!DOCTYPE html>
|
108
|
+
|
109
|
+
<html>
|
110
|
+
|
111
|
+
<head>
|
112
|
+
|
113
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
114
|
+
|
115
|
+
<script type="text/javascript" src="../js/dialog.js" charset="UTF-8">
|
116
|
+
|
117
|
+
</script>
|
118
|
+
|
119
|
+
<title>Test</title>
|
120
|
+
|
121
|
+
<script type="text/javascript">
|
122
|
+
|
123
|
+
<!--
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
function register() {
|
128
|
+
|
129
|
+
if(window.confirm('登録')){
|
130
|
+
|
131
|
+
return true;
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
else{
|
136
|
+
|
137
|
+
return false;
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
}
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
// -->
|
146
|
+
|
147
|
+
</script>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
</head>
|
152
|
+
|
153
|
+
<body>
|
154
|
+
|
155
|
+
<h1>Test</h1>
|
156
|
+
|
157
|
+
<p>詳細</p>
|
158
|
+
|
159
|
+
<form action = "./Test02" method = "post" onSubmit="return register()" >
|
160
|
+
|
161
|
+
<font color="red">tet1</font>
|
162
|
+
|
163
|
+
<c:forEach var="info" items="${en}" varStatus="status">
|
164
|
+
|
165
|
+
<font color="red">tet2</font>
|
166
|
+
|
167
|
+
<input type="hidden" name="empId" value="${info.id}" >
|
168
|
+
|
169
|
+
<font color="red">tet3</font>
|
170
|
+
|
171
|
+
<table border = 1>
|
172
|
+
|
173
|
+
<tr><td>name</td><td><input type = "text" name = "name" value="${info.name}" ></td></tr>
|
174
|
+
|
175
|
+
</table>
|
176
|
+
|
177
|
+
</c:forEach>
|
178
|
+
|
179
|
+
<input type = "submit" value = "toroku">
|
180
|
+
|
181
|
+
<a href="./Test01"> <button type="button">modoru</button></a><br>
|
182
|
+
|
183
|
+
</form>
|
184
|
+
|
185
|
+
</body>
|
186
|
+
|
187
|
+
</html>
|
188
|
+
|
189
|
+
```
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
```Test02java
|
194
|
+
|
195
|
+
@WebServlet(name = "Test02", urlPatterns = {"/Register"})
|
196
|
+
|
197
|
+
public class Register extends HttpServlet {
|
198
|
+
|
199
|
+
private static final long serialVersionUID = 1L;
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
@Override
|
206
|
+
|
207
|
+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
208
|
+
|
209
|
+
HttpSession session = request.getSession();
|
210
|
+
|
211
|
+
request.setCharacterEncoding("UTF-8");
|
212
|
+
|
213
|
+
if(request.getParameter("eid") != null){
|
214
|
+
|
215
|
+
int id = Integer.parseInt(request.getParameter("id"));
|
216
|
+
|
217
|
+
Dao dao = new Dao();
|
218
|
+
|
219
|
+
ArrayList<Info> Info = dao.selectid(id);
|
220
|
+
|
221
|
+
request.setAttribute("en", Info);
|
222
|
+
|
223
|
+
}
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
request.getRequestDispatcher("/WEB-INF/jsp/test02.jsp").forward(request, response);
|
230
|
+
|
231
|
+
}
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
@Override
|
236
|
+
|
237
|
+
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
238
|
+
|
239
|
+
//省略
|
240
|
+
|
241
|
+
}
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
```
|