質問編集履歴

2

検索ボタンを押した後の画面

2020/08/22 22:46

投稿

kaibasira
kaibasira

スコア15

test CHANGED
@@ -1 +1 @@
1
- 背景赤い部分の高さを変えたい
1
+ 検索結果後の画面表示の背景赤い部分の高さを変えたい
test CHANGED
File without changes

1

javaでなくjspでした

2020/08/22 22:46

投稿

kaibasira
kaibasira

スコア15

test CHANGED
File without changes
test CHANGED
@@ -112,204 +112,182 @@
112
112
 
113
113
 
114
114
 
115
- スタイルシートを使っているjava
116
-
117
-
118
-
119
- ```
120
-
121
- package movie;
122
-
123
-
124
-
125
- import java.sql.Connection;
126
-
127
- import java.sql.PreparedStatement;
128
-
129
- import java.sql.ResultSet;
130
-
131
- import java.util.ArrayList;
132
-
133
-
134
-
135
- public class Model {
136
-
137
- private String q;
138
-
139
- private String c;
140
-
141
- private ArrayList<TitleListResult> results;
142
-
143
-
144
-
145
- public void execute() {
146
-
147
- System.out.println("Hello");
148
-
149
-
150
-
151
- try {
152
-
153
- Connection conn = ConnectUtilMy.connectDatabase();
154
-
155
-
156
-
157
- // 住所の検索
158
-
159
- String sql = "SELECT title_name,years_publication,performance_income,production_cost,public_evaluation,screening_time,genre_name,original_name,cast_name,directed_name "
160
-
161
- + "FROM movie "
162
-
163
- + "inner join original_list on movie.original_number=original_list.original_number "
164
-
165
- + "inner join genre_list on movie.genre_number=genre_list.genre_number "
166
-
167
- + "inner join directed_list on movie.directed_number=directed_list.directed_number "
168
-
169
- + "inner join cast_list on movie.cast_number=cast_list.cast_number ";
170
-
171
-
172
-
173
- PreparedStatement pstmt;
174
-
175
- if (c.equals("全て")) {
176
-
177
- sql += " where title_name like ? or directed_name like ? or cast_name like ?";
178
-
179
- pstmt = conn.prepareStatement(sql);
180
-
181
- pstmt.setString(1, q + "%");
182
-
183
- pstmt.setString(2, q + "%");
184
-
185
- pstmt.setString(3, q + "%");
186
-
187
-
188
-
189
- } else if (c.equals("タイル名")) {
190
-
191
- sql += " where title_name like ?";
192
-
193
- pstmt = conn.prepareStatement(sql);
194
-
195
- pstmt.setString(1, q + "%");
196
-
197
-
198
-
199
- } else if (c.equals("監督名")) {
200
-
201
- sql += " where directed_name like ?";
202
-
203
- pstmt = conn.prepareStatement(sql);
204
-
205
- pstmt.setString(1, q + "%");
206
-
207
-
208
-
209
- } else if (c.equals("主演名")) {
210
-
211
- sql += " where cast_name like ?";
212
-
213
- pstmt = conn.prepareStatement(sql);
214
-
215
- pstmt.setString(1, q + "%");
216
-
217
-
218
-
219
- } else {
220
-
221
- throw new RuntimeException("選択が不正です");
222
-
223
-
224
-
225
- }
226
-
227
- pstmt.setMaxRows(50);
228
-
229
- ResultSet rs = pstmt.executeQuery();
230
-
231
-
232
-
233
- // 検索結果の取得
234
-
235
- results = new ArrayList<TitleListResult>();
115
+ スタイルシートを使っているjsp
116
+
117
+
118
+
119
+ ```
120
+
121
+ <%@page import="movie.TitleListResult"%>
122
+
123
+ <%@page contentType="text/html" pageEncoding="windows-31j"%>
124
+
125
+ <%@page import="java.util.*"%>
126
+
127
+ <!DOCTYPE html>
128
+
129
+
130
+
131
+ <html xmlns="http://www.w3.org/1999/xhtml">
132
+
133
+
134
+
135
+ <head>
136
+
137
+ <meta name="keywords" content="映画 洋画 邦画">
138
+
139
+ <meta http-equiv="content-language" content="ja">
140
+
141
+ <meta http-equiv="content-type" content="text/html:charset=Shift_JIS">
142
+
143
+ <meta http-equiv="content-style-type" content="text/css">
144
+
145
+ <link href="./style.css" rel="stylesheet" type="text/css">
146
+
147
+ <title>映画データベース</title>
148
+
149
+ <meta name="keywords" content="映画">
150
+
151
+ </head>
152
+
153
+ <body background="img/kuro.jpg">
154
+
155
+ <h1 class="title">映画データベース</h1>
156
+
157
+
158
+
159
+ <form method="POST" action="Controller">
160
+
161
+ <input type="text" name="keyword" size="55"
162
+
163
+ placeholder=" キーワードを入力してください"> <input type="submit"
164
+
165
+ value="search"> <input type="search" name="category"
166
+
167
+ list="data1">
168
+
169
+ <datalist id="data1">
170
+
171
+ <option value="全て"></option>
172
+
173
+ <option value="タイトル名"></option>
174
+
175
+ <option value="監督名"></option>
176
+
177
+ <option value="主演名"></option>
178
+
179
+ </datalist>
180
+
181
+
182
+
183
+ </form>
184
+
185
+
186
+
187
+ <%
188
+
189
+ // サーブレッから渡された検索結果を取得する
190
+
191
+ ArrayList<TitleListResult> results = (ArrayList<TitleListResult>)request.getAttribute("results");
192
+
193
+ %>
194
+
195
+
196
+
197
+ <% if (results != null) { %>
198
+
199
+ <h2 class="naka">検索結果</h2>
200
+
201
+ <div id="kensaku">
202
+
203
+
204
+
205
+
206
+
207
+ <ul class="horizontal-list">
208
+
209
+ <% for (TitleListResult result : results) { %>
210
+
211
+ <li class="item">
212
+
213
+ <dl>
214
+
215
+ <dt>監督名</dt>
216
+
217
+ <dd><%= result.Get_directed_name() %></dd>
236
218
 
237
219
 
238
220
 
239
- while (rs.next()) {
240
-
241
- TitleListResult result = new TitleListResult();
242
-
243
- result.Set_movie_name(rs.getString("title_name"));
244
-
245
- result.Set_years_publication(rs.getString("years_publication"));
246
-
247
- result.Set_performance_income(rs.getDouble("performance_income"));
248
-
249
- result.Set_Production_cost(rs.getDouble("production_cost"));
250
-
251
- result.Set_Public_evaluation(rs.getDouble("public_evaluation"));
252
-
253
- result.Set_Screening_time(rs.getString("screening_time"));
254
-
255
- result.Set_Genre_name(rs.getString("genre_name"));
256
-
257
- result.Set_original_name(rs.getString("original_name"));
258
-
259
- result.Set_cast_name(rs.getString("cast_name"));
260
-
261
- result.Set_directed_name(rs.getString("directed_name"));
262
-
263
- results.add(result);
264
-
265
- }
266
-
267
-
268
-
269
- // 切断
270
-
271
- rs.close();
272
-
273
- pstmt.close();
274
-
275
- conn.close();
276
-
277
- } catch (Exception ex) {
278
-
279
- ex.printStackTrace();
280
-
281
- }
282
-
283
- }
284
-
285
-
286
-
287
- public ArrayList<TitleListResult> getResults() {
288
-
289
- return results;
290
-
291
- }
292
-
293
-
294
-
295
- public void setQ(String q) {
296
-
297
- this.q = q;
298
-
299
- }
300
-
301
-
302
-
303
- public void setC(String c) {
304
-
305
- this.c = c;
306
-
307
- }
308
-
309
- }
310
-
311
-
312
-
313
-
314
-
315
- ```
221
+ <dt>タイトル名</dt>
222
+
223
+ <dd><%= result.Get_movie_name() %></dd>
224
+
225
+
226
+
227
+ <dt>ジャンル</dt>
228
+
229
+ <dd><%= result.Get_Genre_name() %></dd>
230
+
231
+
232
+
233
+ <dt>原作</dt>
234
+
235
+ <dd><%= result.Get_original_name() %></dd>
236
+
237
+
238
+
239
+ <dt>主演</dt>
240
+
241
+ <dd><%= result.Get_cast_name() %></dd>
242
+
243
+
244
+
245
+ <dt>公開年</dt>
246
+
247
+ <dd><%= result.Get_years_publication() %></dd>
248
+
249
+
250
+
251
+ <dt>上映時間</dt>
252
+
253
+ <dd><%= result.Get_Screening_time() %></dd>
254
+
255
+
256
+
257
+ <dt>興行収入</dt>
258
+
259
+ <dd><%= result.Get_performance_income() %></dd>
260
+
261
+
262
+
263
+ <dt>制作費</dt>
264
+
265
+ <dd><%= result.Get_Production_cost() %></dd>
266
+
267
+
268
+
269
+ <dt>評価</dt>
270
+
271
+ <dd><%= result.Get_Public_evaluation() %></dd>
272
+
273
+ </dl>
274
+
275
+ </li>
276
+
277
+ <% } %>
278
+
279
+ </ul>
280
+
281
+ </div>
282
+
283
+ <% } %>
284
+
285
+ </body>
286
+
287
+ </htmt>
288
+
289
+
290
+
291
+
292
+
293
+ ```