質問編集履歴
42
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
41
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -532,6 +532,8 @@
|
|
532
532
|
|
533
533
|
を参考にしました
|
534
534
|
|
535
|
+
controller、DTO、Entity、Mapperあっていますでしょうか?
|
536
|
+
|
535
537
|
後name検索をspring4とMyBatis3でやっているサイトとかあれば教えてください。
|
536
538
|
|
537
539
|
参考にします。
|
40
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -182,9 +182,7 @@
|
|
182
182
|
|
183
183
|
|
184
184
|
|
185
|
-
|
186
|
-
|
187
|
-
@RequestMapping(value = "/test/search/", method = RequestMethod.GET)
|
185
|
+
@RequestMapping(value = "/test/search/", method = RequestMethod.GET)
|
188
186
|
|
189
187
|
public String TestSearch(Model model) {
|
190
188
|
|
@@ -192,7 +190,7 @@
|
|
192
190
|
|
193
191
|
model.addAttribute("SearchForm", form);
|
194
192
|
|
195
|
-
model.addAttribute("message", "MyBatis
|
193
|
+
model.addAttribute("message", "MyBatisサンプルです。");
|
196
194
|
|
197
195
|
return "TestSearch1";
|
198
196
|
|
@@ -200,7 +198,7 @@
|
|
200
198
|
|
201
199
|
|
202
200
|
|
203
|
-
@RequestMapping(value = "/test/search/", method = RequestMethod.
|
201
|
+
@RequestMapping(value = "/test/search/{name}", method = RequestMethod.GET)
|
204
202
|
|
205
203
|
public String TestSearch1(@ModelAttribute SearchForm form, Model model) {
|
206
204
|
|
@@ -214,6 +212,8 @@
|
|
214
212
|
|
215
213
|
|
216
214
|
|
215
|
+
|
216
|
+
|
217
217
|
}
|
218
218
|
|
219
219
|
|
39
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -52,10 +52,6 @@
|
|
52
52
|
|
53
53
|
|
54
54
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
55
|
@Autowired
|
60
56
|
|
61
57
|
private TestService testService;
|
@@ -186,25 +182,37 @@
|
|
186
182
|
|
187
183
|
|
188
184
|
|
185
|
+
|
186
|
+
|
189
|
-
|
187
|
+
@RequestMapping(value = "/test/search/", method = RequestMethod.GET)
|
190
|
-
|
188
|
+
|
191
|
-
public String TestSearch(Model model
|
189
|
+
public String TestSearch(Model model) {
|
192
|
-
|
190
|
+
|
193
|
-
|
191
|
+
SearchForm form = new SearchForm();
|
194
|
-
|
195
|
-
|
192
|
+
|
196
|
-
|
197
|
-
|
193
|
+
model.addAttribute("SearchForm", form);
|
198
|
-
|
194
|
+
|
199
|
-
|
195
|
+
model.addAttribute("message", "MyBatisのdeleteサンプルです。");
|
196
|
+
|
200
|
-
|
197
|
+
return "TestSearch1";
|
198
|
+
|
199
|
+
}
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
@RequestMapping(value = "/test/search/", method = RequestMethod.POST)
|
204
|
+
|
205
|
+
public String TestSearch1(@ModelAttribute SearchForm form, Model model) {
|
206
|
+
|
207
|
+
TestDto test= testService.SearchTest1(form.getName());
|
208
|
+
|
201
|
-
|
209
|
+
model.addAttribute("test",test);
|
202
|
-
|
210
|
+
|
203
|
-
return "/test/search
|
211
|
+
return "redirect:/test/search";
|
204
|
-
|
205
|
-
|
206
|
-
|
212
|
+
|
207
|
-
}
|
213
|
+
}
|
214
|
+
|
215
|
+
|
208
216
|
|
209
217
|
}
|
210
218
|
|
@@ -356,9 +364,9 @@
|
|
356
364
|
|
357
365
|
```java
|
358
366
|
|
359
|
-
search.jsp
|
367
|
+
TestSearch1.jsp
|
360
|
-
|
361
|
-
|
368
|
+
|
369
|
+
|
362
370
|
|
363
371
|
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
364
372
|
|
@@ -378,15 +386,11 @@
|
|
378
386
|
|
379
387
|
<body>
|
380
388
|
|
381
|
-
|
382
|
-
|
383
|
-
<form:form
|
384
|
-
|
385
|
-
|
389
|
+
<form:form action="${pageContext.request.contextPath}/test/serach/"
|
386
390
|
|
387
391
|
method="get" modelAttribute="SearchForm">
|
388
392
|
|
389
|
-
<form:input path="name"/>
|
393
|
+
<form:label path="name">名前:</form:label><form:input path="name" size="40" /><br>
|
390
394
|
|
391
395
|
<input type="submit" value="Search"/>
|
392
396
|
|
@@ -414,8 +418,6 @@
|
|
414
418
|
|
415
419
|
</table>
|
416
420
|
|
417
|
-
|
418
|
-
|
419
421
|
</body>
|
420
422
|
|
421
423
|
</html>
|
@@ -510,115 +512,9 @@
|
|
510
512
|
|
511
513
|

|
512
514
|
|
513
|
-
|
514
|
-
|
515
|
-
```java
|
516
|
-
|
517
|
-
|
515
|
+

|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
516
|
+
|
522
|
-
|
523
|
-
private int id;
|
524
|
-
|
525
|
-
private String name;
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
public int getId() {
|
530
|
-
|
531
|
-
return id;
|
532
|
-
|
533
|
-
}
|
534
|
-
|
535
|
-
public void setId(int id) {
|
536
|
-
|
537
|
-
this.id = id;
|
538
|
-
|
539
|
-
}
|
540
|
-
|
541
|
-
public String getName() {
|
542
|
-
|
543
|
-
return name;
|
544
|
-
|
545
|
-
}
|
546
|
-
|
547
|
-
|
517
|
+

|
548
|
-
|
549
|
-
this.name = name;
|
550
|
-
|
551
|
-
}
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
}
|
556
|
-
|
557
|
-
```
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
```Java
|
564
|
-
|
565
|
-
package jp.co.kenshu.form;
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
public class TestForm {
|
570
|
-
|
571
|
-
private int id;
|
572
|
-
|
573
|
-
private String name;
|
574
|
-
|
575
|
-
private int count;
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
public int getId() {
|
580
|
-
|
581
|
-
return id;
|
582
|
-
|
583
|
-
}
|
584
|
-
|
585
|
-
public void setId(int id) {
|
586
|
-
|
587
|
-
this.id = id;
|
588
|
-
|
589
|
-
}
|
590
|
-
|
591
|
-
public String getName() {
|
592
|
-
|
593
|
-
return name;
|
594
|
-
|
595
|
-
}
|
596
|
-
|
597
|
-
public void setName(String name) {
|
598
|
-
|
599
|
-
this.name = name;
|
600
|
-
|
601
|
-
}
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
public int getCount() {
|
606
|
-
|
607
|
-
return count;
|
608
|
-
|
609
|
-
}
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
public void setCount(int count) {
|
614
|
-
|
615
|
-
this.count = count;
|
616
|
-
|
617
|
-
}
|
618
|
-
|
619
|
-
}
|
620
|
-
|
621
|
-
```
|
622
518
|
|
623
519
|
|
624
520
|
|
@@ -626,9 +522,7 @@
|
|
626
522
|
|
627
523
|
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
628
524
|
|
629
|
-
まだエラーがでて動きません。動くようにしたいです。
|
525
|
+
まだエラーがでて動きません。動くようにしたいです。わかる方教えてください。
|
630
|
-
|
631
|
-
わかる方教えてください。
|
632
526
|
|
633
527
|
この部分のせてとかあれば載せます。
|
634
528
|
|
@@ -643,3 +537,11 @@
|
|
643
537
|
参考にします。
|
644
538
|
|
645
539
|
よろしくお願いします。
|
540
|
+
|
541
|
+
後jspはうごくようになりました。
|
542
|
+
|
543
|
+
名前を入力すると400エラーになります。
|
544
|
+
|
545
|
+

|
546
|
+
|
547
|
+

|
38
ソースの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -510,7 +510,53 @@
|
|
510
510
|
|
511
511
|

|
512
512
|
|
513
|
+
|
514
|
+
|
515
|
+
```java
|
516
|
+
|
517
|
+
package jp.co.kenshu.form;
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
public class SearchForm {
|
522
|
+
|
523
|
+
private int id;
|
524
|
+
|
525
|
+
private String name;
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
public int getId() {
|
530
|
+
|
531
|
+
return id;
|
532
|
+
|
533
|
+
}
|
534
|
+
|
535
|
+
public void setId(int id) {
|
536
|
+
|
537
|
+
this.id = id;
|
538
|
+
|
539
|
+
}
|
540
|
+
|
541
|
+
public String getName() {
|
542
|
+
|
543
|
+
return name;
|
544
|
+
|
545
|
+
}
|
546
|
+
|
513
|
-
|
547
|
+
public void setName(String name) {
|
548
|
+
|
549
|
+
this.name = name;
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
|
554
|
+
|
555
|
+
}
|
556
|
+
|
557
|
+
```
|
558
|
+
|
559
|
+
|
514
560
|
|
515
561
|
|
516
562
|
|
37
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -522,7 +522,7 @@
|
|
522
522
|
|
523
523
|
public class TestForm {
|
524
524
|
|
525
|
-
private
|
525
|
+
private int id;
|
526
526
|
|
527
527
|
private String name;
|
528
528
|
|
@@ -530,13 +530,13 @@
|
|
530
530
|
|
531
531
|
|
532
532
|
|
533
|
-
public
|
533
|
+
public int getId() {
|
534
534
|
|
535
535
|
return id;
|
536
536
|
|
537
537
|
}
|
538
538
|
|
539
|
-
public void setId(
|
539
|
+
public void setId(int id) {
|
540
540
|
|
541
541
|
this.id = id;
|
542
542
|
|
36
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -526,7 +526,9 @@
|
|
526
526
|
|
527
527
|
private String name;
|
528
528
|
|
529
|
-
|
529
|
+
private int count;
|
530
|
+
|
531
|
+
|
530
532
|
|
531
533
|
public Integer getId() {
|
532
534
|
|
35
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -526,15 +526,9 @@
|
|
526
526
|
|
527
527
|
private String name;
|
528
528
|
|
529
|
-
|
529
|
+
|
530
|
-
|
531
|
-
|
530
|
+
|
532
|
-
|
533
|
-
private int count;
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
531
|
+
public Integer getId() {
|
538
532
|
|
539
533
|
return id;
|
540
534
|
|
@@ -574,38 +568,6 @@
|
|
574
568
|
|
575
569
|
}
|
576
570
|
|
577
|
-
|
578
|
-
|
579
|
-
public int getCount2() {
|
580
|
-
|
581
|
-
return count2;
|
582
|
-
|
583
|
-
}
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
public void setCount2(int count2) {
|
588
|
-
|
589
|
-
this.count2 = count2;
|
590
|
-
|
591
|
-
}
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
public int getCount3() {
|
596
|
-
|
597
|
-
return count3;
|
598
|
-
|
599
|
-
}
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
public void setCount3(int count3) {
|
604
|
-
|
605
|
-
this.count3 = count3;
|
606
|
-
|
607
|
-
}
|
608
|
-
|
609
571
|
}
|
610
572
|
|
611
573
|
```
|
34
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -506,6 +506,12 @@
|
|
506
506
|
|
507
507
|
```
|
508
508
|
|
509
|
+

|
510
|
+
|
511
|
+

|
512
|
+
|
513
|
+

|
514
|
+
|
509
515
|
|
510
516
|
|
511
517
|
```Java
|
33
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -508,21 +508,27 @@
|
|
508
508
|
|
509
509
|
|
510
510
|
|
511
|
-
```
|
511
|
+
```Java
|
512
|
-
|
513
|
-
|
512
|
+
|
514
|
-
|
515
|
-
package jp.co.kenshu.
|
513
|
+
package jp.co.kenshu.form;
|
516
|
-
|
517
|
-
|
518
|
-
|
514
|
+
|
515
|
+
|
516
|
+
|
519
|
-
public class Test
|
517
|
+
public class TestForm {
|
520
|
-
|
518
|
+
|
521
|
-
private Integer id;
|
519
|
+
private Integer id;
|
522
|
-
|
520
|
+
|
523
|
-
|
521
|
+
private String name;
|
522
|
+
|
524
|
-
|
523
|
+
private int count3;
|
524
|
+
|
525
|
+
private int count2;
|
526
|
+
|
527
|
+
private int count;
|
528
|
+
|
529
|
+
|
530
|
+
|
525
|
-
public Integer getId() {
|
531
|
+
public Integer getId() {
|
526
532
|
|
527
533
|
return id;
|
528
534
|
|
@@ -548,58 +554,58 @@
|
|
548
554
|
|
549
555
|
|
550
556
|
|
557
|
+
public int getCount() {
|
558
|
+
|
559
|
+
return count;
|
560
|
+
|
561
|
+
}
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
public void setCount(int count) {
|
566
|
+
|
567
|
+
this.count = count;
|
568
|
+
|
569
|
+
}
|
570
|
+
|
571
|
+
|
572
|
+
|
573
|
+
public int getCount2() {
|
574
|
+
|
575
|
+
return count2;
|
576
|
+
|
577
|
+
}
|
578
|
+
|
579
|
+
|
580
|
+
|
581
|
+
public void setCount2(int count2) {
|
582
|
+
|
583
|
+
this.count2 = count2;
|
584
|
+
|
585
|
+
}
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
public int getCount3() {
|
590
|
+
|
591
|
+
return count3;
|
592
|
+
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
public void setCount3(int count3) {
|
598
|
+
|
599
|
+
this.count3 = count3;
|
600
|
+
|
601
|
+
}
|
602
|
+
|
551
603
|
}
|
552
604
|
|
553
605
|
```
|
554
606
|
|
555
607
|
|
556
608
|
|
557
|
-
```java
|
558
|
-
|
559
|
-
entity
|
560
|
-
|
561
|
-
package jp.co.kenshu.entity;
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
public class Test {
|
566
|
-
|
567
|
-
private Integer id;
|
568
|
-
|
569
|
-
private String name;
|
570
|
-
|
571
|
-
public Integer getId() {
|
572
|
-
|
573
|
-
return id;
|
574
|
-
|
575
|
-
}
|
576
|
-
|
577
|
-
public void setId(Integer id) {
|
578
|
-
|
579
|
-
this.id = id;
|
580
|
-
|
581
|
-
}
|
582
|
-
|
583
|
-
public String getName() {
|
584
|
-
|
585
|
-
return name;
|
586
|
-
|
587
|
-
}
|
588
|
-
|
589
|
-
public void setName(String name) {
|
590
|
-
|
591
|
-
this.name = name;
|
592
|
-
|
593
|
-
}
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
}
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
```
|
602
|
-
|
603
609
|
|
604
610
|
|
605
611
|
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
32
ソースの改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -508,6 +508,100 @@
|
|
508
508
|
|
509
509
|
|
510
510
|
|
511
|
+
```java
|
512
|
+
|
513
|
+
DTO
|
514
|
+
|
515
|
+
package jp.co.kenshu.dto.test;
|
516
|
+
|
517
|
+
|
518
|
+
|
519
|
+
public class TestDto {
|
520
|
+
|
521
|
+
private Integer id;
|
522
|
+
|
523
|
+
private String name;
|
524
|
+
|
525
|
+
public Integer getId() {
|
526
|
+
|
527
|
+
return id;
|
528
|
+
|
529
|
+
}
|
530
|
+
|
531
|
+
public void setId(Integer id) {
|
532
|
+
|
533
|
+
this.id = id;
|
534
|
+
|
535
|
+
}
|
536
|
+
|
537
|
+
public String getName() {
|
538
|
+
|
539
|
+
return name;
|
540
|
+
|
541
|
+
}
|
542
|
+
|
543
|
+
public void setName(String name) {
|
544
|
+
|
545
|
+
this.name = name;
|
546
|
+
|
547
|
+
}
|
548
|
+
|
549
|
+
|
550
|
+
|
551
|
+
}
|
552
|
+
|
553
|
+
```
|
554
|
+
|
555
|
+
|
556
|
+
|
557
|
+
```java
|
558
|
+
|
559
|
+
entity
|
560
|
+
|
561
|
+
package jp.co.kenshu.entity;
|
562
|
+
|
563
|
+
|
564
|
+
|
565
|
+
public class Test {
|
566
|
+
|
567
|
+
private Integer id;
|
568
|
+
|
569
|
+
private String name;
|
570
|
+
|
571
|
+
public Integer getId() {
|
572
|
+
|
573
|
+
return id;
|
574
|
+
|
575
|
+
}
|
576
|
+
|
577
|
+
public void setId(Integer id) {
|
578
|
+
|
579
|
+
this.id = id;
|
580
|
+
|
581
|
+
}
|
582
|
+
|
583
|
+
public String getName() {
|
584
|
+
|
585
|
+
return name;
|
586
|
+
|
587
|
+
}
|
588
|
+
|
589
|
+
public void setName(String name) {
|
590
|
+
|
591
|
+
this.name = name;
|
592
|
+
|
593
|
+
}
|
594
|
+
|
595
|
+
|
596
|
+
|
597
|
+
}
|
598
|
+
|
599
|
+
|
600
|
+
|
601
|
+
```
|
602
|
+
|
603
|
+
|
604
|
+
|
511
605
|
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
512
606
|
|
513
607
|
まだエラーがでて動きません。動くようにしたいです。
|
31
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -492,28 +492,18 @@
|
|
492
492
|
|
493
493
|
```
|
494
494
|
|
495
|
+
|
496
|
+
|
495
497
|
```
|
496
498
|
|
497
499
|
HTTPステータス 400 -
|
498
500
|
|
499
501
|
|
500
502
|
|
501
|
-
|
502
|
-
|
503
503
|
説明 The request sent by the client was syntactically incorrect.
|
504
504
|
|
505
505
|
|
506
506
|
|
507
|
-
Skipping MapperFactoryBean with name 'testMapper' and 'jp.co.kenshu.mapper.TestMapper' mapperInterface. Bean already defined with the same name! [日 10 23 05:26:54 JST 2016]
|
508
|
-
|
509
|
-
警告: No MyBatis mapper was found in '[jp.co.kenshu.mapper]' package. Please check your configuration. [日 10 23 05:26:54 JST 2016]
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
No mapping found for HTTP request with URI [/SpringKenshu/list/search] in DispatcherServlet withname 'dispatcherServlet' [日 10 23 05:27:16 JST 2016]
|
514
|
-
|
515
|
-
|
516
|
-
|
517
507
|
```
|
518
508
|
|
519
509
|
|
30
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -480,20 +480,14 @@
|
|
480
480
|
|
481
481
|
</bean>
|
482
482
|
|
483
|
+
<bean id="transactionManager"
|
484
|
+
|
483
|
-
|
485
|
+
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
484
|
-
|
486
|
+
|
485
|
-
<property name="
|
487
|
+
<property name="dataSource" ref="dataSource" />
|
486
488
|
|
487
489
|
</bean>
|
488
490
|
|
489
|
-
<bean id="transactionManager"
|
490
|
-
|
491
|
-
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
492
|
-
|
493
|
-
<property name="dataSource" ref="dataSource" />
|
494
|
-
|
495
|
-
</bean>
|
496
|
-
|
497
491
|
|
498
492
|
|
499
493
|
```
|
29
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -386,8 +386,6 @@
|
|
386
386
|
|
387
387
|
method="get" modelAttribute="SearchForm">
|
388
388
|
|
389
|
-
<form:label path="name">Name</form:label>
|
390
|
-
|
391
389
|
<form:input path="name"/>
|
392
390
|
|
393
391
|
<input type="submit" value="Search"/>
|
@@ -408,9 +406,9 @@
|
|
408
406
|
|
409
407
|
<tr>
|
410
408
|
|
411
|
-
<td>${test.
|
409
|
+
<td>${test.id}</td>
|
412
|
-
|
410
|
+
|
413
|
-
<td>${test.
|
411
|
+
<td>${test.name}</td>
|
414
412
|
|
415
413
|
</tr>
|
416
414
|
|
28
ソースの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -348,7 +348,7 @@
|
|
348
348
|
|
349
349
|
|
350
350
|
|
351
|
-

|
352
352
|
|
353
353
|
|
354
354
|
|
27
書式の修正
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
26
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
25
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -534,6 +534,12 @@
|
|
534
534
|
|
535
535
|
この部分のせてとかあれば載せます。
|
536
536
|
|
537
|
+
後どなたかこのソースコードでうごくか確認してもらえないでしょうか?
|
538
|
+
|
539
|
+
[リンク内容](http://qiita.com/yu_eguchi/items/5bdda6f6ee7baf441870)
|
540
|
+
|
541
|
+
を参考にしました
|
542
|
+
|
537
543
|
後name検索をspring4とMyBatis3でやっているサイトとかあれば教えてください。
|
538
544
|
|
539
545
|
参考にします。
|
24
書式の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
|
7
7
|
os winodws10、java1.8、tomcat8.0、spring4
|
8
8
|
|
9
|
+
|
10
|
+
|
9
11
|
```java
|
10
12
|
|
11
13
|
package jp.co.kenshu.controller;
|
@@ -524,13 +526,11 @@
|
|
524
526
|
|
525
527
|
|
526
528
|
|
527
|
-
|
528
|
-
|
529
529
|
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
530
530
|
|
531
|
-
エラーがでて動きません。動くようにしたいです。
|
531
|
+
まだエラーがでて動きません。動くようにしたいです。
|
532
|
-
|
532
|
+
|
533
|
-
|
533
|
+
わかる方教えてください。
|
534
534
|
|
535
535
|
この部分のせてとかあれば載せます。
|
536
536
|
|
@@ -538,4 +538,4 @@
|
|
538
538
|
|
539
539
|
参考にします。
|
540
540
|
|
541
|
-
よろしくお願いします。
|
541
|
+
よろしくお願いします。
|
23
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -528,7 +528,7 @@
|
|
528
528
|
|
529
529
|
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
530
530
|
|
531
|
-
エラーがでて動きません。
|
531
|
+
エラーがでて動きません。動くようにしたいです。
|
532
532
|
|
533
533
|
ソースここ違うんじゃないとかあれば教えてください。
|
534
534
|
|
22
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -528,10 +528,14 @@
|
|
528
528
|
|
529
529
|
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
530
530
|
|
531
|
-
で
|
531
|
+
エラーがでて動きません。
|
532
532
|
|
533
533
|
ソースここ違うんじゃないとかあれば教えてください。
|
534
534
|
|
535
535
|
この部分のせてとかあれば載せます。
|
536
536
|
|
537
|
+
後name検索をspring4とMyBatis3でやっているサイトとかあれば教えてください。
|
538
|
+
|
539
|
+
参考にします。
|
540
|
+
|
537
541
|
よろしくお願いします。助けてください。
|
21
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
教えてください。
|
6
6
|
|
7
|
-
java1.8、tomcat8.0、spring4
|
7
|
+
os winodws10、java1.8、tomcat8.0、spring4
|
8
8
|
|
9
9
|
```java
|
10
10
|
|
20
ソースの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,8 +34,6 @@
|
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
-
import jp.co.kenshu.dto.test.SearchDto;
|
38
|
-
|
39
37
|
import jp.co.kenshu.dto.test.TestDto;
|
40
38
|
|
41
39
|
import jp.co.kenshu.form.SearchForm;
|
@@ -50,150 +48,312 @@
|
|
50
48
|
|
51
49
|
public class TestController {
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
model
|
70
|
-
|
71
|
-
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
@Autowired
|
58
|
+
|
59
|
+
private TestService testService;
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
@RequestMapping(value = "/test/{id}", method = RequestMethod.GET)
|
66
|
+
|
67
|
+
public String test(Model model, @PathVariable int id) {
|
68
|
+
|
69
|
+
TestDto test = testService.getTest(id);
|
70
|
+
|
71
|
+
model.addAttribute("message", "MyBatisのサンプルです");
|
72
|
+
|
73
|
+
model.addAttribute("test", test);
|
74
|
+
|
75
|
+
return "test";
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
@RequestMapping(value = "/test/", method = RequestMethod.GET)
|
82
|
+
|
83
|
+
public String testAll(Model model) {
|
84
|
+
|
85
|
+
List<TestDto> tests = testService.getTestAll();
|
86
|
+
|
87
|
+
model.addAttribute("message", "MyBatisの全件取得サンプルです");
|
88
|
+
|
89
|
+
model.addAttribute("tests", tests);
|
90
|
+
|
91
|
+
return "test";
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
@RequestMapping(value = "/test/insert/input/", method = RequestMethod.GET)
|
96
|
+
|
97
|
+
public String testInsert(Model model) {
|
98
|
+
|
99
|
+
TestForm form = new TestForm();
|
100
|
+
|
101
|
+
model.addAttribute("testForm", form);
|
102
|
+
|
103
|
+
model.addAttribute("message", "MyBatisのinsertサンプルです。");
|
104
|
+
|
105
|
+
return "testInsert";
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
@RequestMapping(value = "/test/insert/input/", method = RequestMethod.POST)
|
112
|
+
|
113
|
+
public String testInsert(@ModelAttribute TestForm form, Model model) {
|
114
|
+
|
115
|
+
int count= testService.insertTest(form.getName());
|
116
|
+
|
117
|
+
return "redirect:/test/";
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
@RequestMapping(value = "/test/delete/input/", method = RequestMethod.GET)
|
122
|
+
|
123
|
+
public String testDelete(Model model) {
|
124
|
+
|
125
|
+
TestForm form = new TestForm();
|
126
|
+
|
127
|
+
model.addAttribute("testForm", form);
|
128
|
+
|
129
|
+
model.addAttribute("message", "MyBatisのdeleteサンプルです。");
|
130
|
+
|
131
|
+
return "testDelete";
|
132
|
+
|
133
|
+
}
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
@RequestMapping(value = "/test/delete/input/", method = RequestMethod.POST)
|
138
|
+
|
139
|
+
public String testDelete(@ModelAttribute TestForm form, Model model) {
|
140
|
+
|
141
|
+
int count = testService.deleteTest(form.getId());
|
142
|
+
|
143
|
+
return "redirect:/test/";
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
@RequestMapping(value = "/test/update/input/{id}/", method = RequestMethod.GET)
|
148
|
+
|
149
|
+
public String testUpdate(Model model, @PathVariable int id) {
|
150
|
+
|
151
|
+
TestDto test = testService.getTest(id);
|
152
|
+
|
153
|
+
model.addAttribute("message", "MyBatisのUpdateサンプルです");
|
154
|
+
|
155
|
+
model.addAttribute("test", test);
|
156
|
+
|
157
|
+
TestForm form = new TestForm();
|
158
|
+
|
159
|
+
form.setId(test.getId());
|
160
|
+
|
161
|
+
form.setName(test.getName());
|
162
|
+
|
163
|
+
model.addAttribute("testForm", form);
|
164
|
+
|
165
|
+
return "testUpdate";
|
166
|
+
|
167
|
+
}
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
@RequestMapping(value = "/test/update/input/{id}/", method = RequestMethod.POST)
|
172
|
+
|
173
|
+
public String testUpdate(Model model, @ModelAttribute TestForm form) {
|
174
|
+
|
175
|
+
TestDto dto = new TestDto();
|
176
|
+
|
177
|
+
BeanUtils.copyProperties(form, dto);
|
178
|
+
|
179
|
+
int count = testService.updateTest(dto);
|
180
|
+
|
181
|
+
return "redirect:/test/";
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
@RequestMapping(value = "/test/search/", method = RequestMethod.GET)
|
188
|
+
|
189
|
+
public String TestSearch(Model model, @ModelAttribute SearchForm form, @PathVariable String name) {
|
190
|
+
|
191
|
+
TestDto dto = new TestDto();
|
192
|
+
|
193
|
+
dto.setName(form.getName());
|
194
|
+
|
195
|
+
TestDto test = testService.SearchTest1(name);
|
196
|
+
|
197
|
+
model.addAttribute("message","MyBatisの全件取得サンプルです");
|
198
|
+
|
199
|
+
model.addAttribute("test",test);
|
200
|
+
|
201
|
+
return "/test/search/";
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
}
|
72
206
|
|
73
207
|
}
|
74
208
|
|
209
|
+
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
```java
|
216
|
+
|
217
|
+
package jp.co.kenshu.service;
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
import java.util.LinkedList;
|
222
|
+
|
223
|
+
import java.util.List;
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
import org.springframework.beans.BeanUtils;
|
228
|
+
|
229
|
+
import org.springframework.beans.factory.annotation.Autowired;
|
230
|
+
|
231
|
+
import org.springframework.stereotype.Service;
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
import jp.co.kenshu.dto.test.TestDto;
|
236
|
+
|
237
|
+
import jp.co.kenshu.entity.Test;
|
238
|
+
|
239
|
+
import jp.co.kenshu.mapper.TestMapper;
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
@Service
|
244
|
+
|
245
|
+
public class TestService {
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
@Autowired
|
250
|
+
|
251
|
+
private TestMapper testMapper;
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
public TestDto getTest(Integer id) {
|
256
|
+
|
257
|
+
TestDto dto = new TestDto();
|
258
|
+
|
259
|
+
Test entity = testMapper.getTest(id);
|
260
|
+
|
261
|
+
BeanUtils.copyProperties(entity, dto);
|
262
|
+
|
263
|
+
return dto;
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
public List<TestDto> getTestAll() {
|
268
|
+
|
269
|
+
List<Test> testList = testMapper.getTestAll();
|
270
|
+
|
271
|
+
List<TestDto> resultList = convertToDto(testList);
|
272
|
+
|
273
|
+
return resultList;
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
private List<TestDto> convertToDto(List<Test> testList) {
|
280
|
+
|
281
|
+
List<TestDto> resultList = new LinkedList<>();
|
282
|
+
|
283
|
+
for (Test entity : testList) {
|
284
|
+
|
285
|
+
TestDto dto = new TestDto();
|
286
|
+
|
287
|
+
BeanUtils.copyProperties(entity, dto);
|
288
|
+
|
289
|
+
resultList.add(dto);
|
290
|
+
|
291
|
+
}
|
292
|
+
|
293
|
+
return resultList;
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
public int insertTest(String name) {
|
298
|
+
|
299
|
+
int count = testMapper.insertTest(name);
|
300
|
+
|
301
|
+
return count;
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
public int deleteTest(int id) {
|
306
|
+
|
307
|
+
int count = testMapper.deleteTest(id);
|
308
|
+
|
309
|
+
return count;
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
public int updateTest(TestDto dto) {
|
316
|
+
|
317
|
+
int count = testMapper.updateTest(dto);
|
318
|
+
|
319
|
+
return count;
|
320
|
+
|
321
|
+
}
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
public TestDto SearchTest1(String name) {
|
326
|
+
|
327
|
+
TestDto dto = new TestDto();
|
328
|
+
|
329
|
+
Test entity = testMapper.SearchTest1(name);
|
330
|
+
|
331
|
+
BeanUtils.copyProperties(entity, dto);
|
332
|
+
|
333
|
+
return dto;
|
334
|
+
|
335
|
+
}
|
336
|
+
|
337
|
+
|
338
|
+
|
75
339
|
}
|
76
340
|
|
77
|
-
|
78
|
-
|
79
|
-
```
|
341
|
+
```
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+

|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+

|
350
|
+
|
351
|
+
|
80
352
|
|
81
353
|
|
82
354
|
|
83
355
|
```java
|
84
356
|
|
85
|
-
package jp.co.kenshu.service;
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
import java.util.LinkedList;
|
90
|
-
|
91
|
-
import java.util.List;
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
import org.springframework.beans.BeanUtils;
|
96
|
-
|
97
|
-
import org.springframework.beans.factory.annotation.Autowired;
|
98
|
-
|
99
|
-
import org.springframework.stereotype.Service;
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
import jp.co.kenshu.dto.test.SearchDto;
|
104
|
-
|
105
|
-
import jp.co.kenshu.dto.test.TestDto;
|
106
|
-
|
107
|
-
import jp.co.kenshu.entity.Test;
|
108
|
-
|
109
|
-
import jp.co.kenshu.mapper.TestMapper;
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
@Service
|
114
|
-
|
115
|
-
public class TestService {
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
public TestDto SearchTest1(String name){
|
120
|
-
|
121
|
-
TestDto dto = new TestDto();
|
122
|
-
|
123
|
-
Test entity = testMapper.SearchTest1(name);
|
124
|
-
|
125
|
-
BeanUtils.copyProperties(entity, dto);
|
126
|
-
|
127
|
-
return dto;
|
128
|
-
|
129
|
-
}
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
```
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
```java
|
138
|
-
|
139
|
-
package jp.co.kenshu.mapper;
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
import java.util.List;
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
import jp.co.kenshu.dto.test.TestDto;
|
148
|
-
|
149
|
-
import jp.co.kenshu.entity.Test;
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
public interface TestMapper {
|
154
|
-
|
155
|
-
Test SearchTest1(String name);
|
156
|
-
|
157
|
-
}
|
158
|
-
|
159
|
-
```
|
160
|
-
|
161
|
-
```
|
162
|
-
|
163
|
-
<?xml version="1.0" encoding="UTF-8" ?>
|
164
|
-
|
165
|
-
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
166
|
-
|
167
|
-
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
168
|
-
|
169
|
-
<mapper namespace="jp.co.kenshu.mapper.TestMapper">
|
170
|
-
|
171
|
-
<resultMap id="TestResult" type="jp.co.kenshu.entity.Test">
|
172
|
-
|
173
|
-
<result column="id" property="id" />
|
174
|
-
|
175
|
-
<result column="name" property="name" />
|
176
|
-
|
177
|
-
</resultMap>
|
178
|
-
|
179
|
-
<select id="SearchTest1" resultType="jp.co.kenshu.entity.Test" parameterType="String" resultMap="TestResult">
|
180
|
-
|
181
|
-
select id, name
|
182
|
-
|
183
|
-
from test
|
184
|
-
|
185
|
-
where name = #{name}
|
186
|
-
|
187
|
-
</select>
|
188
|
-
|
189
|
-
</mapper>
|
190
|
-
|
191
|
-
```
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
```java
|
196
|
-
|
197
357
|
search.jsp
|
198
358
|
|
199
359
|
<!DOCTYPE html>
|
19
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,6 +54,8 @@
|
|
54
54
|
|
55
55
|
private TestService testService;
|
56
56
|
|
57
|
+
@RequestMapping(value = "/test/search/", method = RequestMethod.GET)
|
58
|
+
|
57
59
|
public String TestSearch(Model model, @ModelAttribute SearchForm form, @PathVariable String name){
|
58
60
|
|
59
61
|
TestDto dto = new TestDto();
|
@@ -66,7 +68,7 @@
|
|
66
68
|
|
67
69
|
model.addAttribute("test",test);
|
68
70
|
|
69
|
-
return "/
|
71
|
+
return "/test/search/";
|
70
72
|
|
71
73
|
}
|
72
74
|
|
18
更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -118,7 +118,7 @@
|
|
118
118
|
|
119
119
|
TestDto dto = new TestDto();
|
120
120
|
|
121
|
-
Test entity = testMapper.SearchTest1(
|
121
|
+
Test entity = testMapper.SearchTest1(name);
|
122
122
|
|
123
123
|
BeanUtils.copyProperties(entity, dto);
|
124
124
|
|
17
編集
test
CHANGED
File without changes
|
test
CHANGED
@@ -298,9 +298,9 @@
|
|
298
298
|
|
299
299
|
<property name="url" value="jdbc:mysql://localhost/test" />
|
300
300
|
|
301
|
-
<property name="username" value="
|
301
|
+
<property name="username" value="" />
|
302
|
-
|
302
|
+
|
303
|
-
<property name="password" value="
|
303
|
+
<property name="password" value="" />
|
304
304
|
|
305
305
|
</bean>
|
306
306
|
|
16
ソース修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,11 +54,13 @@
|
|
54
54
|
|
55
55
|
private TestService testService;
|
56
56
|
|
57
|
-
@RequestMapping(value = "/list/search/", method = RequestMethod.GET)
|
58
|
-
|
59
|
-
public String TestSearch(Model model, @ModelAttribute SearchForm form, @PathVariable String name{
|
57
|
+
public String TestSearch(Model model, @ModelAttribute SearchForm form, @PathVariable String name){
|
58
|
+
|
60
|
-
|
59
|
+
TestDto dto = new TestDto();
|
60
|
+
|
61
|
+
dto.setName(form.getName());
|
62
|
+
|
61
|
-
TestDto test = testService.SearchTest1(
|
63
|
+
TestDto test = testService.SearchTest1(name);
|
62
64
|
|
63
65
|
model.addAttribute("message","MyBatisの全件取得サンプルです");
|
64
66
|
|
@@ -66,9 +68,11 @@
|
|
66
68
|
|
67
69
|
return "/list/search/";
|
68
70
|
|
69
|
-
|
71
|
+
}
|
70
|
-
|
72
|
+
|
71
|
-
}
|
73
|
+
}
|
74
|
+
|
75
|
+
|
72
76
|
|
73
77
|
```
|
74
78
|
|
@@ -334,103 +338,23 @@
|
|
334
338
|
|
335
339
|
```
|
336
340
|
|
337
|
-
HTTPステータス
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
ty
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
例外
|
356
|
-
|
357
|
-
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Source must not be null
|
358
|
-
|
359
|
-
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
|
360
|
-
|
361
|
-
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
|
362
|
-
|
363
|
-
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
|
364
|
-
|
365
|
-
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
|
366
|
-
|
367
|
-
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
|
368
|
-
|
369
|
-
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
原因
|
376
|
-
|
377
|
-
java.lang.IllegalArgumentException: Source must not be null
|
378
|
-
|
379
|
-
org.springframework.util.Assert.notNull(Assert.java:112)
|
380
|
-
|
381
|
-
org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:596)
|
382
|
-
|
383
|
-
org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:542)
|
384
|
-
|
385
|
-
jp.co.kenshu.service.TestService.SearchTest1(TestService.java:58)
|
386
|
-
|
387
|
-
jp.co.kenshu.controller.TestController.TestSearch(TestController.java:90)
|
388
|
-
|
389
|
-
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
390
|
-
|
391
|
-
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
392
|
-
|
393
|
-
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
394
|
-
|
395
|
-
java.lang.reflect.Method.invoke(Method.java:497)
|
396
|
-
|
397
|
-
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
|
398
|
-
|
399
|
-
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
|
400
|
-
|
401
|
-
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
|
402
|
-
|
403
|
-
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
|
404
|
-
|
405
|
-
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
|
406
|
-
|
407
|
-
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
|
408
|
-
|
409
|
-
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
|
410
|
-
|
411
|
-
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
|
412
|
-
|
413
|
-
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
|
414
|
-
|
415
|
-
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
|
416
|
-
|
417
|
-
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
|
418
|
-
|
419
|
-
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
|
420
|
-
|
421
|
-
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
|
422
|
-
|
423
|
-
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
```
|
428
|
-
|
429
|
-
```
|
430
|
-
|
431
|
-
Eclipseのログ
|
432
|
-
|
433
|
-
Servlet.service() for servlet [dispatcherServlet] in context with path [/SpringKenshu] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Source must not be null] with root cause
|
341
|
+
HTTPステータス 400 -
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
説明 The request sent by the client was syntactically incorrect.
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
Skipping MapperFactoryBean with name 'testMapper' and 'jp.co.kenshu.mapper.TestMapper' mapperInterface. Bean already defined with the same name! [日 10 23 05:26:54 JST 2016]
|
352
|
+
|
353
|
+
警告: No MyBatis mapper was found in '[jp.co.kenshu.mapper]' package. Please check your configuration. [日 10 23 05:26:54 JST 2016]
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
No mapping found for HTTP request with URI [/SpringKenshu/list/search] in DispatcherServlet withname 'dispatcherServlet' [日 10 23 05:27:16 JST 2016]
|
434
358
|
|
435
359
|
|
436
360
|
|
15
ソース
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
@RequestMapping(value = "/list/search/", method = RequestMethod.GET)
|
58
58
|
|
59
|
-
public String TestSearch(SearchForm form,
|
59
|
+
public String TestSearch(Model model, @ModelAttribute SearchForm form, @PathVariable String name{
|
60
60
|
|
61
61
|
TestDto test = testService.SearchTest1(form.getName());
|
62
62
|
|
14
ソース変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
@RequestMapping(value = "/list/search/", method = RequestMethod.GET)
|
58
58
|
|
59
|
-
public String TestSearch(SearchForm form,Model model) {
|
59
|
+
public String TestSearch(SearchForm form,Model model, @PathVariable String name) {
|
60
60
|
|
61
61
|
TestDto test = testService.SearchTest1(form.getName());
|
62
62
|
|
13
ソース変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
public String TestSearch(SearchForm form,Model model) {
|
60
60
|
|
61
|
-
|
61
|
+
TestDto test = testService.SearchTest1(form.getName());
|
62
62
|
|
63
63
|
model.addAttribute("message","MyBatisの全件取得サンプルです");
|
64
64
|
|
12
ソース、エラーの変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -440,11 +440,11 @@
|
|
440
440
|
|
441
441
|
|
442
442
|
|
443
|
-
いろいろ考えたりアドバイスをもらって直しました。
|
443
|
+
いろいろ考えたり、アドバイスをもらっていろいろ今回直しました。
|
444
|
-
|
444
|
+
|
445
|
-
でも動きません。
|
445
|
+
でもまだ動きません。
|
446
|
-
|
446
|
+
|
447
|
-
ソース
|
447
|
+
ソースここ違うんじゃないとかあれば教えてください。
|
448
448
|
|
449
449
|
この部分のせてとかあれば載せます。
|
450
450
|
|
11
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -110,11 +110,11 @@
|
|
110
110
|
|
111
111
|
|
112
112
|
|
113
|
-
public
|
113
|
+
public TestDto SearchTest1(String name){
|
114
|
-
|
114
|
+
|
115
|
-
|
115
|
+
TestDto dto = new TestDto();
|
116
|
-
|
116
|
+
|
117
|
-
Test entity = testMapper.SearchTest1(
|
117
|
+
Test entity = testMapper.SearchTest1(("固定文字列"));
|
118
118
|
|
119
119
|
BeanUtils.copyProperties(entity, dto);
|
120
120
|
|
10
情報の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -444,6 +444,8 @@
|
|
444
444
|
|
445
445
|
でも動きません。
|
446
446
|
|
447
|
-
|
447
|
+
ソースもあっているのかここ違うんじゃないとかあれば教えてください。
|
448
|
+
|
449
|
+
この部分のせてとかあれば載せます。
|
448
450
|
|
449
451
|
よろしくお願いします。助けてください。
|
9
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,11 +58,11 @@
|
|
58
58
|
|
59
59
|
public String TestSearch(SearchForm form,Model model) {
|
60
60
|
|
61
|
-
SearchDto test
|
61
|
+
SearchDto test = testService.SearchTest1(form.getName());
|
62
62
|
|
63
63
|
model.addAttribute("message","MyBatisの全件取得サンプルです");
|
64
64
|
|
65
|
-
model.addAttribute("test
|
65
|
+
model.addAttribute("test",test);
|
66
66
|
|
67
67
|
return "/list/search/";
|
68
68
|
|
8
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -424,9 +424,21 @@
|
|
424
424
|
|
425
425
|
|
426
426
|
|
427
|
-
|
428
|
-
|
429
|
-
```
|
427
|
+
```
|
428
|
+
|
429
|
+
```
|
430
|
+
|
431
|
+
Eclipseのログ
|
432
|
+
|
433
|
+
Servlet.service() for servlet [dispatcherServlet] in context with path [/SpringKenshu] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Source must not be null] with root cause
|
434
|
+
|
435
|
+
|
436
|
+
|
437
|
+
```
|
438
|
+
|
439
|
+
|
440
|
+
|
441
|
+
|
430
442
|
|
431
443
|
いろいろ考えたりアドバイスをもらって直しました。
|
432
444
|
|
7
書籍の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -332,14 +332,106 @@
|
|
332
332
|
|
333
333
|
```
|
334
334
|
|
335
|
-
|
335
|
+
```
|
336
|
+
|
336
|
-
|
337
|
+
HTTPステータス 500 - Request processing failed; nested exception is java.lang.IllegalArgumentException: Source must not be null
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
337
|
-
|
343
|
+
type 例外レポート
|
344
|
+
|
345
|
+
|
346
|
+
|
338
|
-
|
347
|
+
メッセージ Request processing failed; nested exception is java.lang.IllegalArgumentException: Source must not be null
|
348
|
+
|
349
|
+
|
350
|
+
|
339
|
-
|
351
|
+
説明 The server encountered an internal error that prevented it from fulfilling this request.
|
352
|
+
|
353
|
+
|
354
|
+
|
340
|
-
|
355
|
+
例外
|
356
|
+
|
341
|
-
|
357
|
+
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.lang.IllegalArgumentException: Source must not be null
|
358
|
+
|
359
|
+
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
|
360
|
+
|
361
|
+
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
|
362
|
+
|
363
|
+
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
|
364
|
+
|
365
|
+
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
|
366
|
+
|
367
|
+
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
|
368
|
+
|
369
|
+
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
原因
|
376
|
+
|
377
|
+
java.lang.IllegalArgumentException: Source must not be null
|
378
|
+
|
379
|
+
org.springframework.util.Assert.notNull(Assert.java:112)
|
380
|
+
|
381
|
+
org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:596)
|
382
|
+
|
383
|
+
org.springframework.beans.BeanUtils.copyProperties(BeanUtils.java:542)
|
384
|
+
|
385
|
+
jp.co.kenshu.service.TestService.SearchTest1(TestService.java:58)
|
386
|
+
|
387
|
+
jp.co.kenshu.controller.TestController.TestSearch(TestController.java:90)
|
388
|
+
|
389
|
+
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
|
390
|
+
|
391
|
+
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
|
392
|
+
|
393
|
+
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
|
394
|
+
|
395
|
+
java.lang.reflect.Method.invoke(Method.java:497)
|
396
|
+
|
397
|
+
org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
|
398
|
+
|
399
|
+
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
|
400
|
+
|
401
|
+
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
|
402
|
+
|
403
|
+
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:776)
|
404
|
+
|
405
|
+
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:705)
|
406
|
+
|
407
|
+
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
|
408
|
+
|
409
|
+
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959)
|
410
|
+
|
411
|
+
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893)
|
412
|
+
|
413
|
+
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:966)
|
414
|
+
|
415
|
+
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:857)
|
416
|
+
|
417
|
+
javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
|
418
|
+
|
419
|
+
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:842)
|
420
|
+
|
421
|
+
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
|
422
|
+
|
423
|
+
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
```
|
430
|
+
|
431
|
+
いろいろ考えたりアドバイスをもらって直しました。
|
432
|
+
|
433
|
+
でも動きません。
|
342
434
|
|
343
435
|
不足分があれば載せますので教えてください。
|
344
436
|
|
345
|
-
よろしくお願いします。
|
437
|
+
よろしくお願いします。助けてください。
|
6
書式変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
private TestService testService;
|
56
56
|
|
57
|
-
@RequestMapping(value = "/search/", method = RequestMethod.GET)
|
57
|
+
@RequestMapping(value = "/list/search/", method = RequestMethod.GET)
|
58
58
|
|
59
59
|
public String TestSearch(SearchForm form,Model model) {
|
60
60
|
|
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
model.addAttribute("tests",tests);
|
66
66
|
|
67
|
-
return "search";
|
67
|
+
return "/list/search/";
|
68
68
|
|
69
69
|
}
|
70
70
|
|
@@ -170,9 +170,9 @@
|
|
170
170
|
|
171
171
|
</resultMap>
|
172
172
|
|
173
|
-
<select id="SearchTest1" parameterType="String">
|
173
|
+
<select id="SearchTest1" resultType="jp.co.kenshu.entity.Test" parameterType="String" resultMap="TestResult">
|
174
|
-
|
174
|
+
|
175
|
-
|
175
|
+
select id, name
|
176
176
|
|
177
177
|
from test
|
178
178
|
|
@@ -214,7 +214,7 @@
|
|
214
214
|
|
215
215
|
<form:form
|
216
216
|
|
217
|
-
action="${pageContext.request.contextPath}/search/"
|
217
|
+
action="${pageContext.request.contextPath}/list/search/"
|
218
218
|
|
219
219
|
method="get" modelAttribute="SearchForm">
|
220
220
|
|
@@ -252,6 +252,10 @@
|
|
252
252
|
|
253
253
|
</body>
|
254
254
|
|
255
|
+
</html>
|
256
|
+
|
257
|
+
|
258
|
+
|
255
259
|
```
|
256
260
|
|
257
261
|
|
@@ -332,11 +336,7 @@
|
|
332
336
|
|
333
337
|
|
334
338
|
|
335
|
-
|
339
|
+
|
336
|
-
|
337
|
-

|
338
|
-
|
339
|
-

|
340
340
|
|
341
341
|
|
342
342
|
|
5
test
CHANGED
File without changes
|
test
CHANGED
@@ -340,4 +340,6 @@
|
|
340
340
|
|
341
341
|
|
342
342
|
|
343
|
-
不足分があれば載せますので
|
343
|
+
不足分があれば載せますので教えてください。
|
344
|
+
|
345
|
+
よろしくお願いします。
|
4
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,9 +4,7 @@
|
|
4
4
|
|
5
5
|
教えてください。
|
6
6
|
|
7
|
-
|
7
|
+
java1.8、tomcat8.0、spring4
|
8
|
-
|
9
|
-
|
10
8
|
|
11
9
|
```java
|
12
10
|
|
@@ -339,3 +337,7 @@
|
|
339
337
|

|
340
338
|
|
341
339
|

|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
不足分があれば載せますのでよろしくお願いします
|
3
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
spring4+MyBatisで検索画面を作っているのですが、うまくいきません。
|
2
2
|
|
3
3
|
エラーがでます。
|
4
4
|
|
@@ -260,16 +260,6 @@
|
|
260
260
|
|
261
261
|
```
|
262
262
|
|
263
|
-
HTTPステータス 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'jp.co.kenshu.mapper.TestMapper.SearchTest1'. It's likely that neither a Result Type nor a Result Map was specified.
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
```
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
```
|
272
|
-
|
273
263
|
mvc-config.xml
|
274
264
|
|
275
265
|
<context:component-scan base-package="jp.co.kenshu" />
|
@@ -339,3 +329,13 @@
|
|
339
329
|
|
340
330
|
|
341
331
|
```
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
エラー内容
|
338
|
+
|
339
|
+

|
340
|
+
|
341
|
+

|
2
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
spring4+MyBatisで検索画面を作っているのですが、うまくいきません。
|
1
|
+
](3c00c7e622073b49403409e44f2bc170.jpeg)spring4+MyBatisで検索画面を作っているのですが、うまくいきません。
|
2
2
|
|
3
3
|
エラーがでます。
|
4
4
|
|
1
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -262,4 +262,80 @@
|
|
262
262
|
|
263
263
|
HTTPステータス 500 - Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: A query was run and no Result Maps were found for the Mapped Statement 'jp.co.kenshu.mapper.TestMapper.SearchTest1'. It's likely that neither a Result Type nor a Result Map was specified.
|
264
264
|
|
265
|
+
|
266
|
+
|
265
|
-
```
|
267
|
+
```
|
268
|
+
|
269
|
+
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
mvc-config.xml
|
274
|
+
|
275
|
+
<context:component-scan base-package="jp.co.kenshu" />
|
276
|
+
|
277
|
+
<mvc:annotation-driven />
|
278
|
+
|
279
|
+
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
|
280
|
+
|
281
|
+
<property name="basename" value="classpath:ValidatorMessages" />
|
282
|
+
|
283
|
+
</bean>
|
284
|
+
|
285
|
+
<bean
|
286
|
+
|
287
|
+
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
|
288
|
+
|
289
|
+
<!-- Example: a logical view name of 'showMessage' is mapped to '/WEB-INF/jsp/showMessage.jsp' -->
|
290
|
+
|
291
|
+
<property name="prefix" value="/WEB-INF/view/" />
|
292
|
+
|
293
|
+
<property name="suffix" value=".jsp" />
|
294
|
+
|
295
|
+
</bean>
|
296
|
+
|
297
|
+
<!-- DataSource -->
|
298
|
+
|
299
|
+
<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource">
|
300
|
+
|
301
|
+
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
|
302
|
+
|
303
|
+
<property name="url" value="jdbc:mysql://localhost/test" />
|
304
|
+
|
305
|
+
<property name="username" value="root" />
|
306
|
+
|
307
|
+
<property name="password" value="ichioka" />
|
308
|
+
|
309
|
+
</bean>
|
310
|
+
|
311
|
+
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
312
|
+
|
313
|
+
<property name="dataSource" ref="dataSource" />
|
314
|
+
|
315
|
+
</bean>
|
316
|
+
|
317
|
+
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
318
|
+
|
319
|
+
<property name="basePackage" value="jp.co.kenshu.mapper" />
|
320
|
+
|
321
|
+
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
|
322
|
+
|
323
|
+
</bean>
|
324
|
+
|
325
|
+
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
326
|
+
|
327
|
+
<property name="basePackage" value="jp.co.kenshu.mapper" />
|
328
|
+
|
329
|
+
</bean>
|
330
|
+
|
331
|
+
<bean id="transactionManager"
|
332
|
+
|
333
|
+
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
|
334
|
+
|
335
|
+
<property name="dataSource" ref="dataSource" />
|
336
|
+
|
337
|
+
</bean>
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
```
|