質問編集履歴

3

インデント修正

2018/09/24 15:14

投稿

tt2
tt2

スコア14

test CHANGED
File without changes
test CHANGED
@@ -90,7 +90,7 @@
90
90
 
91
91
  foo.setName("テスト01");
92
92
 
93
-     request.getSession().setAttribute("foo" , foo);
93
+ request.getSession().setAttribute("foo" , foo);
94
94
 
95
95
  return "menu";
96
96
 

2

前回の修正時に転記漏れがあったため修正

2018/09/24 15:14

投稿

tt2
tt2

スコア14

test CHANGED
File without changes
test CHANGED
@@ -90,6 +90,8 @@
90
90
 
91
91
  foo.setName("テスト01");
92
92
 
93
+     request.getSession().setAttribute("foo" , foo);
94
+
93
95
  return "menu";
94
96
 
95
97
  }

1

コードの書き方を修正

2018/09/24 15:11

投稿

tt2
tt2

スコア14

test CHANGED
File without changes
test CHANGED
@@ -76,10 +76,48 @@
76
76
 
77
77
  ◆実行プログラム
78
78
 
79
- Controller内で以下の処理を記述
79
+ ```Java
80
80
 
81
- Foo foo = new Foo();
81
+ @Controller
82
82
 
83
- foo.setName("テスト01");
83
+ public class WelcomeController {
84
84
 
85
- request.getSession().setAttribute("foo" , foo);
85
+ RequestMapping("/")
86
+
87
+ public String home() {
88
+
89
+ Foo foo = new Foo();
90
+
91
+ foo.setName("テスト01");
92
+
93
+ return "menu";
94
+
95
+ }
96
+
97
+ }
98
+
99
+
100
+
101
+ @Component
102
+
103
+ @Scope(value="session", proxyMode=ScopedProxyMode.TARGET_CLASS)
104
+
105
+ public class Foo {
106
+
107
+ private String name;
108
+
109
+ public String getName() {
110
+
111
+ return name;
112
+
113
+ }
114
+
115
+ public void setName(String name) {
116
+
117
+ this.name = name;
118
+
119
+ }
120
+
121
+ }
122
+
123
+ ```