質問編集履歴

11

2018/12/18 14:36

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -34,7 +34,9 @@
34
34
 
35
35
  request.open('POST', url);
36
36
 
37
+
38
+
37
- ちなみにの書き方だとしたらurlはどのように書くのが正解でしょうか?
39
+ ちなみにの書き方だとしたらurlはどのように書くのが正解でしょうか?
38
40
 
39
41
  今はhttp://localhost:8080/helloで実行していますが、これをurlに書けば下記のcontrollerのindex()に飛ぶのでしょうか?
40
42
 

10

2018/12/18 14:36

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -26,11 +26,17 @@
26
26
 
27
27
 
28
28
 
29
- 以下の書き方かと思ったのですが、urlも分からず詰まっていま
29
+ 以下の書き方かと思ったのですが、どの書き方が正しいのか分からため質問いたしした
30
+
31
+
30
32
 
31
33
  var request = new XMLHttpRequest();
32
34
 
33
35
  request.open('POST', url);
36
+
37
+ ちなみにこの書き方だとしたらurlはどのように書くのが正解でしょうか?
38
+
39
+ 今はhttp://localhost:8080/helloで実行していますが、これをurlに書けば下記のcontrollerのindex()に飛ぶのでしょうか?
34
40
 
35
41
 
36
42
 

9

2018/12/18 14:36

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
File without changes

8

2018/12/18 12:36

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -23,6 +23,16 @@
23
23
 
24
24
 
25
25
  この3から4の遷移の時に、jsからhttpリクエストを飛ばし、controllerクラスで受け取りたいです。
26
+
27
+
28
+
29
+ 以下の書き方かと思ったのですが、urlも分からず詰まっています。
30
+
31
+ var request = new XMLHttpRequest();
32
+
33
+ request.open('POST', url);
34
+
35
+
26
36
 
27
37
 
28
38
 

7

2018/12/18 12:36

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
 
48
48
 
49
- ```import org.springframework.stereotype.Controller;
49
+ import org.springframework.stereotype.Controller;
50
50
 
51
51
  import org.springframework.web.bind.annotation.RequestMapping;
52
52
 
@@ -68,4 +68,4 @@
68
68
 
69
69
 
70
70
 
71
- }```
71
+ }

6

2018/12/18 12:32

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -58,7 +58,7 @@
58
58
 
59
59
 
60
60
 
61
- @RequestMapping("/hello", method=RequestMethod.POST )
61
+ @RequestMapping("/hello",method=RequestMethod.POST )
62
62
 
63
63
  public String index() {
64
64
 

5

2018/12/18 12:31

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -26,11 +26,27 @@
26
26
 
27
27
 
28
28
 
29
+ <環境>
30
+
31
+ Windows
32
+
33
+ Eclipse
34
+
35
+ spring boot
36
+
37
+ Thymeleaf
29
38
 
30
39
 
31
- ```java
32
40
 
41
+
42
+
43
+ こんな感じのcontrollerを想定してます。
44
+
45
+ Thymeleafもよくわからないのでcontrollerの書き方も本当は違う感じなのかもです。
46
+
47
+
48
+
33
- import org.springframework.stereotype.Controller;
49
+ ```import org.springframework.stereotype.Controller;
34
50
 
35
51
  import org.springframework.web.bind.annotation.RequestMapping;
36
52
 

4

2018/12/18 12:31

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -26,7 +26,11 @@
26
26
 
27
27
 
28
28
 
29
+
30
+
31
+ ```java
32
+
29
- ```import org.springframework.stereotype.Controller;
33
+ import org.springframework.stereotype.Controller;
30
34
 
31
35
  import org.springframework.web.bind.annotation.RequestMapping;
32
36
 

3

2018/12/18 12:28

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -26,11 +26,7 @@
26
26
 
27
27
 
28
28
 
29
- ```Controller.java
30
-
31
-
32
-
33
- import org.springframework.stereotype.Controller;
29
+ ```import org.springframework.stereotype.Controller;
34
30
 
35
31
  import org.springframework.web.bind.annotation.RequestMapping;
36
32
 

2

2018/12/18 12:27

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -23,3 +23,33 @@
23
23
 
24
24
 
25
25
  この3から4の遷移の時に、jsからhttpリクエストを飛ばし、controllerクラスで受け取りたいです。
26
+
27
+
28
+
29
+ ```Controller.java
30
+
31
+
32
+
33
+ import org.springframework.stereotype.Controller;
34
+
35
+ import org.springframework.web.bind.annotation.RequestMapping;
36
+
37
+
38
+
39
+ @Controller
40
+
41
+ public class Controller {
42
+
43
+
44
+
45
+ @RequestMapping("/hello", method=RequestMethod.POST )
46
+
47
+ public String index() {
48
+
49
+ --省略--
50
+
51
+ }
52
+
53
+
54
+
55
+ }```

1

2018/12/18 12:27

投稿

yrds
yrds

スコア10

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,7 @@
1
+ 疎いので上手くかけないかもしれませんが、よろしくお願いします。
2
+
3
+
4
+
1
5
  <質問>
2
6
 
3
7
  jsからhttpリクエストを飛ばし、controllerクラスの@RequestMappingで受ける方法
@@ -10,8 +14,12 @@
10
14
 
11
15
  1.画面のボタン押下(html)
12
16
 
13
- 2.入力チェック
17
+ 2.入力チェック(js)
14
18
 
15
19
  3.確認ダイアログ(js)でok押下
16
20
 
17
- 4.
21
+ 4.入力値をDBに登録(java)
22
+
23
+
24
+
25
+ この3から4の遷移の時に、jsからhttpリクエストを飛ばし、controllerクラスで受け取りたいです。