Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +13 -0
- 02 - Core Java/060 Dynamic Method Dispatch.mp4 +3 -0
- 02 - Core Java/062 Object Class equals toString hashcode.mp4 +3 -0
- 02 - Core Java/063 Upcasting and Downcasting.mp4 +3 -0
- 02 - Core Java/064 Wrapper Class.mp4 +3 -0
- 03 - Advance Java/001 Project 1- Introduction.mp4 +3 -0
- 03 - Advance Java/002 Project 1- QuestionService and Question class.mp4 +3 -0
- 03 - Advance Java/003 Project 1- Hard Coded Questions and Display them.mp4 +3 -0
- 03 - Advance Java/004 Project 1- Play Quiz.mp4 +3 -0
- 03 - Advance Java/005 Project 1- Calculate Score.mp4 +3 -0
- 03 - Advance Java/006 Abstract keyword.mp4 +3 -0
- 03 - Advance Java/007 Inner class.mp4 +3 -0
- 03 - Advance Java/008 Anonymous Inner class.mp4 +3 -0
- 03 - Advance Java/010 What is Interface.mp4 +3 -0
- 12 - Spring Boot Web/009 Source-Code.url +2 -0
- 12 - Spring Boot Web/010 RequestMapping_en.srt +376 -0
- 12 - Spring Boot Web/010 Source-Code.url +2 -0
- 12 - Spring Boot Web/011 Sending data to Controller_en.srt +484 -0
- 12 - Spring Boot Web/011 Source-Code.url +2 -0
- 12 - Spring Boot Web/012 Accepting Data the servlet way_en.srt +744 -0
- 12 - Spring Boot Web/012 Source-Code.url +2 -0
- 12 - Spring Boot Web/013 Display Data on Result Page_en.srt +540 -0
- 12 - Spring Boot Web/013 Source-Code.url +2 -0
- 12 - Spring Boot Web/014 RequestParam_en.srt +428 -0
- 12 - Spring Boot Web/014 Source-Code.url +2 -0
- 12 - Spring Boot Web/015 Model Object_en.srt +396 -0
- 12 - Spring Boot Web/015 Source-Code.url +2 -0
- 12 - Spring Boot Web/016 Setting Prefix and Suffix_en.srt +340 -0
- 12 - Spring Boot Web/016 Source-Code.url +2 -0
- 12 - Spring Boot Web/017 ModelAndView_en.srt +456 -0
- 12 - Spring Boot Web/017 Source-Code.url +2 -0
- 12 - Spring Boot Web/018 Need for ModelAttribute_en.srt +748 -0
- 12 - Spring Boot Web/018 Source-Code.url +2 -0
- 12 - Spring Boot Web/019 Source-Code.url +2 -0
- 12 - Spring Boot Web/019 Using ModelAttribute_en.srt +616 -0
- 12 - Spring Boot Web/external-links.txt +51 -0
- 13 - Exploring Web MVC without Spring Boot/001 Spring MVC Introduction_en.srt +316 -0
- 13 - Exploring Web MVC without Spring Boot/002 Creating a Spring MVC Project_en.srt +776 -0
- 13 - Exploring Web MVC without Spring Boot/002 Source-Code.url +2 -0
- 13 - Exploring Web MVC without Spring Boot/003 Running Tomcat in Eclipse_en.srt +228 -0
- 13 - Exploring Web MVC without Spring Boot/003 Source-Code.url +2 -0
- 13 - Exploring Web MVC without Spring Boot/004 Dispatcher Servlet_en.srt +812 -0
- 13 - Exploring Web MVC without Spring Boot/004 Source-Code.url +2 -0
- 13 - Exploring Web MVC without Spring Boot/005 Configuring the DispatcherServlet_en.srt +548 -0
- 13 - Exploring Web MVC without Spring Boot/005 Source-Code.url +2 -0
- 13 - Exploring Web MVC without Spring Boot/006 Internal Resource View Resolver_en.srt +408 -0
- 13 - Exploring Web MVC without Spring Boot/006 Source-Code.url +2 -0
- 13 - Exploring Web MVC without Spring Boot/007 Summary_en.srt +308 -0
- 13 - Exploring Web MVC without Spring Boot/external-links.txt +15 -0
- 14 - Building a Project/001 Building Job App_en.srt +296 -0
.gitattributes
CHANGED
|
@@ -92,3 +92,16 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 92 |
02[[:space:]]-[[:space:]]Core[[:space:]]Java/058[[:space:]]Access[[:space:]]Modifiers.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 93 |
02[[:space:]]-[[:space:]]Core[[:space:]]Java/056[[:space:]]Method[[:space:]]Overriding.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 94 |
02[[:space:]]-[[:space:]]Core[[:space:]]Java/061[[:space:]]Final[[:space:]]keyword.mp4 filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
02[[:space:]]-[[:space:]]Core[[:space:]]Java/058[[:space:]]Access[[:space:]]Modifiers.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 93 |
02[[:space:]]-[[:space:]]Core[[:space:]]Java/056[[:space:]]Method[[:space:]]Overriding.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 94 |
02[[:space:]]-[[:space:]]Core[[:space:]]Java/061[[:space:]]Final[[:space:]]keyword.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 95 |
+
02[[:space:]]-[[:space:]]Core[[:space:]]Java/060[[:space:]]Dynamic[[:space:]]Method[[:space:]]Dispatch.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 96 |
+
02[[:space:]]-[[:space:]]Core[[:space:]]Java/062[[:space:]]Object[[:space:]]Class[[:space:]]equals[[:space:]]toString[[:space:]]hashcode.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 97 |
+
02[[:space:]]-[[:space:]]Core[[:space:]]Java/063[[:space:]]Upcasting[[:space:]]and[[:space:]]Downcasting.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 98 |
+
02[[:space:]]-[[:space:]]Core[[:space:]]Java/064[[:space:]]Wrapper[[:space:]]Class.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 99 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/002[[:space:]]Project[[:space:]]1-[[:space:]]QuestionService[[:space:]]and[[:space:]]Question[[:space:]]class.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 100 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/003[[:space:]]Project[[:space:]]1-[[:space:]]Hard[[:space:]]Coded[[:space:]]Questions[[:space:]]and[[:space:]]Display[[:space:]]them.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 101 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/004[[:space:]]Project[[:space:]]1-[[:space:]]Play[[:space:]]Quiz.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 102 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/001[[:space:]]Project[[:space:]]1-[[:space:]]Introduction.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 103 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/005[[:space:]]Project[[:space:]]1-[[:space:]]Calculate[[:space:]]Score.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 104 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/008[[:space:]]Anonymous[[:space:]]Inner[[:space:]]class.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 105 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/007[[:space:]]Inner[[:space:]]class.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 106 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/006[[:space:]]Abstract[[:space:]]keyword.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 107 |
+
03[[:space:]]-[[:space:]]Advance[[:space:]]Java/010[[:space:]]What[[:space:]]is[[:space:]]Interface.mp4 filter=lfs diff=lfs merge=lfs -text
|
02 - Core Java/060 Dynamic Method Dispatch.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bc9d46f02807b29a077f3b2e6b099473191052518f1597a17f77fd25d7a7b0aa
|
| 3 |
+
size 129233029
|
02 - Core Java/062 Object Class equals toString hashcode.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7c852c2cabe1313a58066dc134b3a4e7f18c557cce975636a4365022d22aaaf3
|
| 3 |
+
size 190406934
|
02 - Core Java/063 Upcasting and Downcasting.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd31327ddd8fa7668fb1d16310feea6bc75b40244da9e96ca0dca86d6f3985e3
|
| 3 |
+
size 102704879
|
02 - Core Java/064 Wrapper Class.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:85cf27831c11f02a53002461ca8a1518dd09dd619b3a033df7d8725de08e102e
|
| 3 |
+
size 145677485
|
03 - Advance Java/001 Project 1- Introduction.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:35be7a4d600f461a21aa0c6ea3f958147ff5df69f57de5eb3f08bbc8fc5be76c
|
| 3 |
+
size 136418515
|
03 - Advance Java/002 Project 1- QuestionService and Question class.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c5de5f0e0e7ab143315fb1eb8e060acbffbb27dfbd37ee1dbc6dbdaa7bcf8575
|
| 3 |
+
size 145550215
|
03 - Advance Java/003 Project 1- Hard Coded Questions and Display them.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:67ba97b25f20a47b8c08a6547e95b84cad6188cbbef9283d9a26945bc1b83a3b
|
| 3 |
+
size 69362437
|
03 - Advance Java/004 Project 1- Play Quiz.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:04b93ed99f219f66b56c85d0def994b2bc3d4e3300685cb4fb161323d0a06935
|
| 3 |
+
size 107860262
|
03 - Advance Java/005 Project 1- Calculate Score.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:736267e1ec3b3a405c6489817ad3596dfd890c8fb747ee1ee8fceb95a32ccf7e
|
| 3 |
+
size 37740181
|
03 - Advance Java/006 Abstract keyword.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1bc255c60390b8acec234115f5f9b657a4a0308740e03c7666a29f16c64d5d02
|
| 3 |
+
size 189686181
|
03 - Advance Java/007 Inner class.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:398fe16f53ef983719ad3443aaca02622a914aed9bad58bf5b9950066e8e65e1
|
| 3 |
+
size 89146904
|
03 - Advance Java/008 Anonymous Inner class.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:43d8d348499aa15af87ce7c8dc6f82de2d4136f42e88de3b0f695ad90ecda971
|
| 3 |
+
size 78822462
|
03 - Advance Java/010 What is Interface.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ab7c6bbb1c08f639eebfdc1872a8a02ba22912992402efc2d9616c045a413741
|
| 3 |
+
size 41653219
|
12 - Spring Boot Web/009 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(bright music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: Okay, so let's solve this problem of mapping.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:08,000
|
| 11 |
+
The thing is, if you want to map this, you don't have
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:08,000 --> 00:00:11,000
|
| 15 |
+
to do any qualification for the XML, luckily.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:11,000 --> 00:00:12,000
|
| 19 |
+
We have to use annotation.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:12,000 --> 00:00:14,000
|
| 23 |
+
Now, which annotation we have to use?
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:14,000 --> 00:00:16,000
|
| 27 |
+
So for this, for mapping the request,
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:16,000 --> 00:00:19,000
|
| 31 |
+
we have to use annotation call RequestMapping.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:19,000 --> 00:00:23,000
|
| 35 |
+
And in this mapping you have to pass the path.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:23,000 --> 00:00:24,000
|
| 39 |
+
The path here is homepage.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:24,000 --> 00:00:26,000
|
| 43 |
+
So whenever someone calls the homepage,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:26,000 --> 00:00:28,000
|
| 47 |
+
this is something I want to execute.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:28,000 --> 00:00:30,000
|
| 51 |
+
It is as simple as that.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:30,000 --> 00:00:32,000
|
| 55 |
+
Just a request mapping, it will come to know
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:32,000 --> 00:00:34,000
|
| 59 |
+
that this is a mapping we have to do,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:34,000 --> 00:00:35,000
|
| 63 |
+
which is for the slash.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:35,000 --> 00:00:36,000
|
| 67 |
+
Yeah, if you're doing for the students,
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:36,000 --> 00:00:37,000
|
| 71 |
+
you can also say student.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:37,000 --> 00:00:39,000
|
| 75 |
+
So you can say slash student,
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:39,000 --> 00:00:40,000
|
| 79 |
+
you will map for slash student,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:40,000 --> 00:00:44,000
|
| 83 |
+
but at this point I want to map it for the slash homepage.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:44,000 --> 00:00:46,000
|
| 87 |
+
And that's the only change you have to make.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:46,000 --> 00:00:50,000
|
| 91 |
+
Let's refresh this taking some time, go back to your browser
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:50,000 --> 00:00:52,000
|
| 95 |
+
and say, refresh, done.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:52,000 --> 00:00:54,000
|
| 99 |
+
Something happened.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:54,000 --> 00:00:56,000
|
| 103 |
+
Okay, it's not the same thing which we were expecting.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:56,000 --> 00:00:59,000
|
| 107 |
+
We were expecting a page.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:00:59,000 --> 00:01:00,000
|
| 111 |
+
But you can see it says,
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:00,000 --> 00:01:04,000
|
| 115 |
+
do you want to allow downloads on local host?
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:04,000 --> 00:01:07,000
|
| 119 |
+
If I say allow, something got downloaded.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:07,000 --> 00:01:10,000
|
| 123 |
+
If I see here it says unknown file. I mean that's weird.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:10,000 --> 00:01:13,000
|
| 127 |
+
I was expecting a output on the page,
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:13,000 --> 00:01:16,000
|
| 131 |
+
but it is giving me a download.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:16,000 --> 00:01:18,000
|
| 135 |
+
But if you really think about this download,
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:18,000 --> 00:01:22,000
|
| 139 |
+
this is actually a file which has your JSP content.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:22,000 --> 00:01:26,000
|
| 143 |
+
So if you see this is the page which we are getting,
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:26,000 --> 00:01:29,000
|
| 147 |
+
I don't want page, I want output, what's happening here?
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:29,000 --> 00:01:31,000
|
| 151 |
+
So we'll talk about what is happening in some time.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:31,000 --> 00:01:33,000
|
| 155 |
+
It is not working the way we wanted,
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:33,000 --> 00:01:38,000
|
| 159 |
+
but at least we are able to call this home.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:38,000 --> 00:01:41,000
|
| 163 |
+
This is working, right? So we have reached to this point
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:41,000 --> 00:01:43,000
|
| 167 |
+
where we are able to call a particular method,
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:43,000 --> 00:01:45,000
|
| 171 |
+
depend upon the mapping.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:45,000 --> 00:01:47,000
|
| 175 |
+
And request mapping is not the only method we have.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:47,000 --> 00:01:48,000
|
| 179 |
+
So apart from RequestMapping,
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:48,000 --> 00:01:50,000
|
| 183 |
+
we also have GetMapping, PostMapping.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:50,000 --> 00:01:52,000
|
| 187 |
+
We'll see that later.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:52,000 --> 00:01:54,000
|
| 191 |
+
So if I say, I'll show you just a method name,
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:54,000 --> 00:01:57,000
|
| 195 |
+
like we got GetMapping, PostMapping,
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:57,000 --> 00:01:59,000
|
| 199 |
+
so we'll see that when to use what.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:59,000 --> 00:02:01,000
|
| 203 |
+
But at this point we're using RequestMapping
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:01,000 --> 00:02:04,000
|
| 207 |
+
to map the request and is able to call the index.jsp.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:04,000 --> 00:02:06,000
|
| 211 |
+
Now question is no, why it's not working.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:06,000 --> 00:02:09,000
|
| 215 |
+
The reason it is not working is because by default,
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:09,000 --> 00:02:12,000
|
| 219 |
+
springboard does not support JSP page.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:12,000 --> 00:02:14,000
|
| 223 |
+
So we have to basically convert.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:14,000 --> 00:02:16,000
|
| 227 |
+
So, remember we talked about conversion,
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:16,000 --> 00:02:18,000
|
| 231 |
+
we have to convert your JSP into Servlet?
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:18,000 --> 00:02:22,000
|
| 235 |
+
Who will do that? And that's where you need a help here.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:22,000 --> 00:02:25,000
|
| 239 |
+
So we have to add one more dependency to achieve that,
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:25,000 --> 00:02:28,000
|
| 243 |
+
which is called a Tomcat Jasper.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:28,000 --> 00:02:32,000
|
| 247 |
+
So I will go to my browser and go to your MEN repository
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:32,000 --> 00:02:35,000
|
| 251 |
+
and search for Tomcat Jasper.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:35,000 --> 00:02:37,000
|
| 255 |
+
This is the library which we want.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:37,000 --> 00:02:41,000
|
| 259 |
+
So if you click on this, okay, which one, which version?
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:41,000 --> 00:02:44,000
|
| 263 |
+
Now this depend upon which version you're using
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:44,000 --> 00:02:45,000
|
| 267 |
+
for your Tomcat.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:45,000 --> 00:02:48,000
|
| 271 |
+
So if you scroll down, the Tomcat version,
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:48,000 --> 00:02:51,000
|
| 275 |
+
which we're using is 10.1.16.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:51,000 --> 00:02:56,000
|
| 279 |
+
Let's use the same one, which is here, click on this,
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:56,000 --> 00:02:57,000
|
| 283 |
+
you need this dependency.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:57,000 --> 00:03:01,000
|
| 287 |
+
Go back, page it here. I don't want this advertisement.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:03:02,000 --> 00:03:05,000
|
| 291 |
+
Okay, let's import this particular package.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:03:05,000 --> 00:03:07,000
|
| 295 |
+
Reload your Maven. And that's done.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:03:07,000 --> 00:03:10,000
|
| 299 |
+
We got this dependency and I hope this time it'll work.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:10,000 --> 00:03:13,000
|
| 303 |
+
So if you go back to your browser now, go back
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:13,000 --> 00:03:15,000
|
| 307 |
+
to your homepage, which was not working.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:15,000 --> 00:03:20,000
|
| 311 |
+
Let's do localhost:8080, enter, and boom,
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:20,000 --> 00:03:22,000
|
| 315 |
+
you got the output, which is hello world.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:22,000 --> 00:03:23,000
|
| 319 |
+
This time it is not saying download is
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:23,000 --> 00:03:27,000
|
| 323 |
+
because now we are able to convert the JSP into Servlet
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:27,000 --> 00:03:28,000
|
| 327 |
+
and that's what is running now.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:29,000 --> 00:03:32,000
|
| 331 |
+
Oh, now you're not thinking, you know,
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:32,000 --> 00:03:33,000
|
| 335 |
+
a lot of dependencies.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:33,000 --> 00:03:35,000
|
| 339 |
+
See, technically we'll not be using JSP in
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:35,000 --> 00:03:36,000
|
| 343 |
+
your actual project, right?
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:36,000 --> 00:03:38,000
|
| 347 |
+
You'll be using some front end technologies.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:38,000 --> 00:03:41,000
|
| 351 |
+
That's the, that's how we are building application now.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:41,000 --> 00:03:44,000
|
| 355 |
+
And what you will be turning there is the data. That's it.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:44,000 --> 00:03:46,000
|
| 359 |
+
So at this point, we are doing a page,
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:46,000 --> 00:03:47,000
|
| 363 |
+
but we'll see how do we return data?
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:47,000 --> 00:03:52,000
|
| 367 |
+
Not the page, but at this point it's working,
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:52,000 --> 00:03:53,000
|
| 371 |
+
so let's be happy with it.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:53,000 --> 00:03:56,000
|
| 375 |
+
And we are using request mapping to map the request.
|
| 376 |
+
|
12 - Spring Boot Web/010 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.10%20RequestMapping
|
12 - Spring Boot Web/011 Sending data to Controller_en.srt
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(bright music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: So we got the homepage, which is hello world.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:08,000
|
| 11 |
+
But then we don't want a simple page here, right?
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:08,000 --> 00:00:10,000
|
| 15 |
+
Maybe I want to perform some operation.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:10,000 --> 00:00:13,000
|
| 19 |
+
See, the entire idea of having a backend
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:13,000 --> 00:00:16,000
|
| 23 |
+
is where a user will request for something.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:16,000 --> 00:00:18,000
|
| 27 |
+
Maybe you want to add two numbers, simplest stuff,
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:18,000 --> 00:00:22,000
|
| 31 |
+
or you want to find the data about something.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:22,000 --> 00:00:24,000
|
| 35 |
+
Or maybe you want to see the listing of a product
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:24,000 --> 00:00:26,000
|
| 39 |
+
by the price.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:26,000 --> 00:00:29,000
|
| 43 |
+
So basically what you're doing is a client sends a request
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:29,000 --> 00:00:30,000
|
| 47 |
+
for the server, server does some processing
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:30,000 --> 00:00:33,000
|
| 51 |
+
and give something back to the client.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:33,000 --> 00:00:35,000
|
| 55 |
+
Now at this point, I don't don't want
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:35,000 --> 00:00:36,000
|
| 59 |
+
to get into complex logic
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:36,000 --> 00:00:39,000
|
| 63 |
+
because we are here to learn Spring Framework,
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:39,000 --> 00:00:42,000
|
| 67 |
+
not to make complex logic.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:42,000 --> 00:00:44,000
|
| 71 |
+
And that's why we'll go for a simple example.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:44,000 --> 00:00:45,000
|
| 75 |
+
How do we add two numbers?
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:45,000 --> 00:00:48,000
|
| 79 |
+
Now, why we are doing this for a simple reason, we want
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:48,000 --> 00:00:50,000
|
| 83 |
+
to send some data to the server.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:50,000 --> 00:00:53,000
|
| 87 |
+
We want to ask server, Hey, you know you have
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:53,000 --> 00:00:54,000
|
| 91 |
+
to do something for me.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:54,000 --> 00:00:56,000
|
| 95 |
+
Sever say, "okay, we'll do it."
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:56,000 --> 00:00:58,000
|
| 99 |
+
Give back the data to the client.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:58,000 --> 00:01:01,000
|
| 103 |
+
That's the process we want to achieve. So how do we do that?
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:01,000 --> 00:01:03,000
|
| 107 |
+
So first of all, in this homepage, I don't want
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:03,000 --> 00:01:05,000
|
| 111 |
+
to simply print a hello world.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:05,000 --> 00:01:08,000
|
| 115 |
+
Maybe I want to add two numbers and to achieve that,
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:08,000 --> 00:01:11,000
|
| 119 |
+
first of all, you need a page where you can add two numbers.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:11,000 --> 00:01:13,000
|
| 123 |
+
So what I will do is I need a form here
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:13,000 --> 00:01:14,000
|
| 127 |
+
so they can submit data.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:14,000 --> 00:01:17,000
|
| 131 |
+
So when I say form, it means I need two text field.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:17,000 --> 00:01:20,000
|
| 135 |
+
I need a button where I can click the button
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:20,000 --> 00:01:24,000
|
| 139 |
+
and this two text field data should go to the server.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:24,000 --> 00:01:26,000
|
| 143 |
+
And for that we have to create a form.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:26,000 --> 00:01:28,000
|
| 147 |
+
Now instead of wasting our time writing the code,
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:28,000 --> 00:01:30,000
|
| 151 |
+
I do have the code with me.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:30,000 --> 00:01:31,000
|
| 155 |
+
So that's our simple form.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:31,000 --> 00:01:35,000
|
| 159 |
+
You can see I'm using a label for enter the first number,
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:35,000 --> 00:01:37,000
|
| 163 |
+
and then we have a text typed
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:37,000 --> 00:01:40,000
|
| 167 |
+
or text box you can say, which is a typed text
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:40,000 --> 00:01:42,000
|
| 171 |
+
and it takes a number.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:42,000 --> 00:01:43,000
|
| 175 |
+
And the ID for that is num1,
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:43,000 --> 00:01:45,000
|
| 179 |
+
because these ID are important.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:45,000 --> 00:01:48,000
|
| 183 |
+
And then the ID for the second one is num2.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:48,000 --> 00:01:51,000
|
| 187 |
+
And then we have a button there which is called submit.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:51,000 --> 00:01:53,000
|
| 191 |
+
And maybe I just want to change this from hello world
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:53,000 --> 00:01:56,000
|
| 195 |
+
to Telusko Calculator.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:56,000 --> 00:02:00,000
|
| 199 |
+
That's it. Nothing fancy, just a simple page here.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:00,000 --> 00:02:02,000
|
| 203 |
+
And now let me restart this
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:02,000 --> 00:02:04,000
|
| 207 |
+
just to see if I can get this page.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:04,000 --> 00:02:06,000
|
| 211 |
+
Is it looking good on the screen?
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:06,000 --> 00:02:10,000
|
| 215 |
+
So go back to your browser and say refresh, take some time
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:10,000 --> 00:02:11,000
|
| 219 |
+
and you can see we got a calculator.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:11,000 --> 00:02:12,000
|
| 223 |
+
Not looking good.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:12,000 --> 00:02:13,000
|
| 227 |
+
But again, we are not here
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:13,000 --> 00:02:16,000
|
| 231 |
+
to make some beautiful things, right?
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:16,000 --> 00:02:18,000
|
| 235 |
+
I mean we want to make beautiful things,
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:18,000 --> 00:02:20,000
|
| 239 |
+
but not in the front end, in the back end.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:20,000 --> 00:02:21,000
|
| 243 |
+
But still it doesn't look good, right?
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:21,000 --> 00:02:23,000
|
| 247 |
+
Let's have something here.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:23,000 --> 00:02:25,000
|
| 251 |
+
So what I will do is I will create a CSS file here
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:27,000 --> 00:02:28,000
|
| 255 |
+
just to style this stuff.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:28,000 --> 00:02:30,000
|
| 259 |
+
Let me create a CSS file here.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:30,000 --> 00:02:33,000
|
| 263 |
+
So I'll say style.css.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:33,000 --> 00:02:38,000
|
| 267 |
+
And in this style.css, I want to have some CSS code.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:38,000 --> 00:02:40,000
|
| 271 |
+
And again, I'm not here to teach you CSS.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:40,000 --> 00:02:43,000
|
| 275 |
+
So let me just get some CSS file here
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:43,000 --> 00:02:45,000
|
| 279 |
+
just to make our page beautiful.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:45,000 --> 00:02:48,000
|
| 283 |
+
And we have to also make sure that we use the CSS here.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:48,000 --> 00:02:51,000
|
| 287 |
+
So I'll put that in the head tag
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:51,000 --> 00:02:53,000
|
| 291 |
+
and we have to provide the link for the CSS
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:53,000 --> 00:02:55,000
|
| 295 |
+
and let me do that here.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:55,000 --> 00:02:56,000
|
| 299 |
+
So basically by doing this,
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:56,000 --> 00:03:00,000
|
| 303 |
+
what we are doing is we are having a CSS in the code so
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:00,000 --> 00:03:03,000
|
| 307 |
+
that it'll make the page bit beautiful, not very beautiful
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:03,000 --> 00:03:06,000
|
| 311 |
+
because we tried to use some Java theme, coffee theme
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:06,000 --> 00:03:08,000
|
| 315 |
+
here with the CSS.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:08,000 --> 00:03:09,000
|
| 319 |
+
Let's see if that works out.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:09,000 --> 00:03:12,000
|
| 323 |
+
Let's run this and taking some time.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:12,000 --> 00:03:15,000
|
| 327 |
+
Okay, so you got a page here.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:15,000 --> 00:03:17,000
|
| 331 |
+
Not great looking but manageable, right?
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:17,000 --> 00:03:20,000
|
| 335 |
+
So we've got a page and I can provide some numbers here.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:20,000 --> 00:03:22,000
|
| 339 |
+
So let's say I want to add six and seven,
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:22,000 --> 00:03:26,000
|
| 343 |
+
and the output I want here is 13.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:26,000 --> 00:03:27,000
|
| 347 |
+
Now of course we will say, Hey, we can do that
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:27,000 --> 00:03:28,000
|
| 351 |
+
with simple JavaScript, right?
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:28,000 --> 00:03:31,000
|
| 355 |
+
We can write a client site code, add this to number,
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:31,000 --> 00:03:32,000
|
| 359 |
+
see we can do whatever we want.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:32,000 --> 00:03:36,000
|
| 363 |
+
We can simply take a mobile phone, get a open the calculator
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:36,000 --> 00:03:37,000
|
| 367 |
+
and add this two numbers.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:37,000 --> 00:03:38,000
|
| 371 |
+
Not the main thing here.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:38,000 --> 00:03:40,000
|
| 375 |
+
The main thing is what if I want
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:40,000 --> 00:03:43,000
|
| 379 |
+
to build a Spring application where the client sends data
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:43,000 --> 00:03:45,000
|
| 383 |
+
to the server and you want to perform some operation.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:45,000 --> 00:03:49,000
|
| 387 |
+
So when I click on submit here, I want this to work.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:49,000 --> 00:03:52,000
|
| 391 |
+
And you can, you can see at this point it says 4 0 4.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:52,000 --> 00:03:54,000
|
| 395 |
+
So basically your server is not happy by saying, hey,
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:03:54,000 --> 00:03:57,000
|
| 399 |
+
you know, you're sending some request
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:03:57,000 --> 00:03:59,000
|
| 403 |
+
and I don't have any idea what you want me to do.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:03:59,000 --> 00:04:02,000
|
| 407 |
+
I would say, okay, it's not very complex.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:04:02,000 --> 00:04:04,000
|
| 411 |
+
If someone sends request for the add.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:04,000 --> 00:04:06,000
|
| 415 |
+
Now you can see when you say submit it,
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:06,000 --> 00:04:08,000
|
| 419 |
+
you're sending a request for the add URL.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:09,000 --> 00:04:12,000
|
| 423 |
+
And if you observe the URL here, which is not visible
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:12,000 --> 00:04:14,000
|
| 427 |
+
by default in Safari,
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:14,000 --> 00:04:15,000
|
| 431 |
+
but you can see we got a URL here,
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:15,000 --> 00:04:19,000
|
| 435 |
+
it says localized:8080/add.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:19,000 --> 00:04:21,000
|
| 439 |
+
Then we are passing two values.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:21,000 --> 00:04:23,000
|
| 443 |
+
So in the URL itself, we are passing the values.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:23,000 --> 00:04:26,000
|
| 447 |
+
Number one value is six, and num two value is seven.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:26,000 --> 00:04:29,000
|
| 451 |
+
And the URL and the request we're sending is for the add.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:29,000 --> 00:04:31,000
|
| 455 |
+
Okay? Initially we were sending the request
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:31,000 --> 00:04:32,000
|
| 459 |
+
for the homepage, but now we are sending the
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:32,000 --> 00:04:33,000
|
| 463 |
+
request for the add.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:33,000 --> 00:04:34,000
|
| 467 |
+
Okay.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:34,000 --> 00:04:36,000
|
| 471 |
+
That means we need a controller
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:36,000 --> 00:04:38,000
|
| 475 |
+
who can accept this request.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:38,000 --> 00:04:41,000
|
| 479 |
+
Now question arise how we look, create that controller.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:41,000 --> 00:04:42,000
|
| 483 |
+
Let's see that in the next video.
|
| 484 |
+
|
12 - Spring Boot Web/011 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.11%20Sending%20data%20to%20Controller
|
12 - Spring Boot Web/012 Accepting Data the servlet way_en.srt
ADDED
|
@@ -0,0 +1,744 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(soft music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: Now, let's try to create a controller
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:08,000
|
| 11 |
+
which can accept this request.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:08,000 --> 00:00:09,000
|
| 15 |
+
Because if you see the HomeController.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:09,000 --> 00:00:13,000
|
| 19 |
+
Of course, we can create a new controller here, a new class,
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:13,000 --> 00:00:16,000
|
| 23 |
+
but then Spring allows you to have multiple controllers
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:16,000 --> 00:00:17,000
|
| 27 |
+
in one controller.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:17,000 --> 00:00:18,000
|
| 31 |
+
So what I'm saying is
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:18,000 --> 00:00:21,000
|
| 35 |
+
Spring allows you to have multiple requests
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:21,000 --> 00:00:24,000
|
| 39 |
+
mapped in one particular controller.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:24,000 --> 00:00:26,000
|
| 43 |
+
And logically, if you have different types of controllers,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:26,000 --> 00:00:28,000
|
| 47 |
+
let's say you have different types of requests.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:28,000 --> 00:00:30,000
|
| 51 |
+
So if you're making an e-commerce website
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:30,000 --> 00:00:34,000
|
| 55 |
+
and you want to request for user, so user addition,
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:34,000 --> 00:00:38,000
|
| 59 |
+
or maybe adding a user, deleting a user, or updating a user,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:38,000 --> 00:00:40,000
|
| 63 |
+
so everything that deals with the user,
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:40,000 --> 00:00:41,000
|
| 67 |
+
you can put that in one controller.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:41,000 --> 00:00:44,000
|
| 71 |
+
Maybe you can have the controller for products
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:44,000 --> 00:00:46,000
|
| 75 |
+
where you can add a product, remove a product,
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:46,000 --> 00:00:48,000
|
| 79 |
+
update a product.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:48,000 --> 00:00:51,000
|
| 83 |
+
You can also have a controller for orders, place the order,
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:51,000 --> 00:00:54,000
|
| 87 |
+
delete the order, change the status of the order.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:54,000 --> 00:00:57,000
|
| 91 |
+
So you can have that in the OrderController.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:57,000 --> 00:00:59,000
|
| 95 |
+
But here, since we only have two controls now,
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:59,000 --> 00:01:02,000
|
| 99 |
+
let's work with the same HomeController.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:02,000 --> 00:01:02,000
|
| 103 |
+
So what I will do is,
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:02,000 --> 00:01:05,000
|
| 107 |
+
if you want to have something that will accept the request,
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:05,000 --> 00:01:06,000
|
| 111 |
+
you have to create another method.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:06,000 --> 00:01:09,000
|
| 115 |
+
So at this point, I will say public String
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:09,000 --> 00:01:12,000
|
| 119 |
+
because maybe I want to return a page, of course, right?
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:12,000 --> 00:01:15,000
|
| 123 |
+
When you add two numbers, you also want a page,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:15,000 --> 00:01:17,000
|
| 127 |
+
and that's what you're expecting in the browser.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:17,000 --> 00:01:20,000
|
| 131 |
+
So if you see in the output, when you send this request,
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:20,000 --> 00:01:23,000
|
| 135 |
+
this should be another page.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:23,000 --> 00:01:24,000
|
| 139 |
+
Okay, so that means I have to return something,
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:24,000 --> 00:01:26,000
|
| 143 |
+
and then we can have a method name.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:26,000 --> 00:01:28,000
|
| 147 |
+
Method name can be anything. I will say add here
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:28,000 --> 00:01:30,000
|
| 151 |
+
and open bracket close.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:30,000 --> 00:01:33,000
|
| 155 |
+
Okay, now here, I want to return the name of a page.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:33,000 --> 00:01:34,000
|
| 159 |
+
So what's should be the name of the page?
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:34,000 --> 00:01:36,000
|
| 163 |
+
I will simply say return.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:36,000 --> 00:01:38,000
|
| 167 |
+
We can return any page name.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:38,000 --> 00:01:42,000
|
| 171 |
+
I will say return "result.jsp".
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:42,000 --> 00:01:44,000
|
| 175 |
+
And, okay, that's done.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:44,000 --> 00:01:45,000
|
| 179 |
+
But then will it be getting called?
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:45,000 --> 00:01:47,000
|
| 183 |
+
Of course not.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:47,000 --> 00:01:49,000
|
| 187 |
+
So basically, we have to map it.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:49,000 --> 00:01:50,000
|
| 191 |
+
Now how do you map it?
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:50,000 --> 00:01:53,000
|
| 195 |
+
Of course, for mapping, we can use @RequestMapping.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:53,000 --> 00:01:56,000
|
| 199 |
+
And then in the bracket, we can mention the URL.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:56,000 --> 00:02:01,000
|
| 203 |
+
The URL for this is add, because if you see on the homepage,
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:01,000 --> 00:02:04,000
|
| 207 |
+
we are saying, "This is my website name,
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:04,000 --> 00:02:09,000
|
| 211 |
+
and then this is the URL," the URL path basically,
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:09,000 --> 00:02:10,000
|
| 215 |
+
and that's what you have to mention.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:10,000 --> 00:02:11,000
|
| 219 |
+
This is for the add request,
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:11,000 --> 00:02:13,000
|
| 223 |
+
and this method should be called.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:13,000 --> 00:02:14,000
|
| 227 |
+
Is it really working?
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:14,000 --> 00:02:15,000
|
| 231 |
+
Let's try.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:15,000 --> 00:02:17,000
|
| 235 |
+
So what I will do is, before making any changes,
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:17,000 --> 00:02:19,000
|
| 239 |
+
let's rerun this and see the output.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:19,000 --> 00:02:21,000
|
| 243 |
+
Go back to your browser,
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:21,000 --> 00:02:23,000
|
| 247 |
+
and I will just say "Submit" once again,
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:23,000 --> 00:02:27,000
|
| 251 |
+
because I have not made any changes in the index.jsp.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:27,000 --> 00:02:30,000
|
| 255 |
+
I will click on "Submit," and we got an error.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:30,000 --> 00:02:32,000
|
| 259 |
+
It may not be able to find it,
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:32,000 --> 00:02:34,000
|
| 263 |
+
or maybe I will just refresh the page.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:37,000 --> 00:02:39,000
|
| 267 |
+
Is the mapping happening?
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:39,000 --> 00:02:40,000
|
| 271 |
+
Maybe it is happening,
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:40,000 --> 00:02:42,000
|
| 275 |
+
or maybe it is searching for result.jsp.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:42,000 --> 00:02:44,000
|
| 279 |
+
Not able to find it the result.jsp.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:44,000 --> 00:02:45,000
|
| 283 |
+
To prove that or to check that,
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:45,000 --> 00:02:49,000
|
| 287 |
+
we can say "in add" just to see if this is working.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:49,000 --> 00:02:50,000
|
| 291 |
+
You know, we should always go step by step;
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:50,000 --> 00:02:53,000
|
| 295 |
+
otherwise, we are not sure at what point we got the error.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:53,000 --> 00:02:55,000
|
| 299 |
+
So I'm just saying "in add" now.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:55,000 --> 00:02:59,000
|
| 303 |
+
Let's go back here and say "Submit,"
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:00,000 --> 00:03:02,000
|
| 307 |
+
and you can see in this it says "in add."
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:02,000 --> 00:03:05,000
|
| 311 |
+
So that means, yes, we are able to call this.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:05,000 --> 00:03:08,000
|
| 315 |
+
But now, it's not just about calling this, right?
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:08,000 --> 00:03:10,000
|
| 319 |
+
Basically, it's not able to find result.jsp.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:10,000 --> 00:03:14,000
|
| 323 |
+
Do we have result.jsp in the file, or we don't yet?
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:14,000 --> 00:03:15,000
|
| 327 |
+
So let me create a file,
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:15,000 --> 00:03:18,000
|
| 331 |
+
or maybe I will just copy-paste this index.jsp here
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:18,000 --> 00:03:21,000
|
| 335 |
+
with a different name: result.jsp.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:21,000 --> 00:03:24,000
|
| 339 |
+
And we don't need a form here, okay?
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:24,000 --> 00:03:26,000
|
| 343 |
+
What we need is to print something.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:26,000 --> 00:03:30,000
|
| 347 |
+
So I'll print "Result is."
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:30,000 --> 00:03:30,000
|
| 351 |
+
That's it.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:30,000 --> 00:03:32,000
|
| 355 |
+
Nothing fancy, I'm just saying "Result is."
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:32,000 --> 00:03:34,000
|
| 359 |
+
If I refresh, you can see it says "Result is."
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:34,000 --> 00:03:36,000
|
| 363 |
+
So it is able to find the page now,
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:36,000 --> 00:03:37,000
|
| 367 |
+
but we are not printing anything.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:37,000 --> 00:03:40,000
|
| 371 |
+
So what is happening is, when you send the first request,
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:40,000 --> 00:03:41,000
|
| 375 |
+
the request goes to the homepage.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:41,000 --> 00:03:43,000
|
| 379 |
+
It is bringing index.jsp.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:43,000 --> 00:03:47,000
|
| 383 |
+
From index.jsp, you are basically sending an add request,
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:47,000 --> 00:03:48,000
|
| 387 |
+
and the add request says,
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:48,000 --> 00:03:50,000
|
| 391 |
+
"Okay, we have to call result.jsp."
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:50,000 --> 00:03:53,000
|
| 395 |
+
But the question arise, who is doing this mapping?
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:03:53,000 --> 00:03:54,000
|
| 399 |
+
If you go back to servlets,
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:03:54,000 --> 00:03:55,000
|
| 403 |
+
remember, for every servlet
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:03:55,000 --> 00:03:58,000
|
| 407 |
+
we have to do the mapping in the XML file.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:03:58,000 --> 00:04:01,000
|
| 411 |
+
We are not doing mapping here, so who is calling it?
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:01,000 --> 00:04:03,000
|
| 415 |
+
So the thing is, there's something called DispatcherServlet.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:03,000 --> 00:04:05,000
|
| 419 |
+
Again, we will not be discussing much
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:05,000 --> 00:04:06,000
|
| 423 |
+
about DispatcherServlet now.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:06,000 --> 00:04:07,000
|
| 427 |
+
We will be talking about that later.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:07,000 --> 00:04:09,000
|
| 431 |
+
But there is DispatcherServlet
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:09,000 --> 00:04:11,000
|
| 435 |
+
who is responsible for mapping all these requests.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:11,000 --> 00:04:13,000
|
| 439 |
+
So it sees, "Okay, what is the request?
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:13,000 --> 00:04:15,000
|
| 443 |
+
This is the request, call this method.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:15,000 --> 00:04:17,000
|
| 447 |
+
This is the request, call this method.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:17,000 --> 00:04:19,000
|
| 451 |
+
Someone is returning index.jsp, search for it."
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:19,000 --> 00:04:22,000
|
| 455 |
+
So that's the job of DispatcherServlet.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:22,000 --> 00:04:23,000
|
| 459 |
+
Again, we will discuss that later.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:23,000 --> 00:04:25,000
|
| 463 |
+
But yeah, it is able to call it.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:25,000 --> 00:04:27,000
|
| 467 |
+
Okay, so that's the step one.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:27,000 --> 00:04:30,000
|
| 471 |
+
The next step is, basically, we have to accept the values.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:30,000 --> 00:04:34,000
|
| 475 |
+
Remember, in the browser, we are sending these values.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:34,000 --> 00:04:36,000
|
| 479 |
+
We have to accept them.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:36,000 --> 00:04:37,000
|
| 483 |
+
How will you do that?
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:04:37,000 --> 00:04:38,000
|
| 487 |
+
See there are two ways of doing it:
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:04:38,000 --> 00:04:41,000
|
| 491 |
+
one is the servlet way, and the second is the Spring way.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:04:41,000 --> 00:04:43,000
|
| 495 |
+
Let's start with the servlet way,
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:04:43,000 --> 00:04:44,000
|
| 499 |
+
and then we'll move towards the Spring way.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:04:44,000 --> 00:04:48,000
|
| 503 |
+
In servlet, if you want to accept the data from a client,
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:04:48,000 --> 00:04:51,000
|
| 507 |
+
we have to use something called HttpServletRequest.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:04:51,000 --> 00:04:53,000
|
| 511 |
+
We have done that before as well, right?
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:04:53,000 --> 00:04:57,000
|
| 515 |
+
So in this bracket, I can simply say HttpServletRequest.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:04:58,000 --> 00:04:59,000
|
| 519 |
+
I can create the object,
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:04:59,000 --> 00:05:02,000
|
| 523 |
+
or I can create a reference called req.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:05:02,000 --> 00:05:03,000
|
| 527 |
+
Now, the question arises,
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:05:03,000 --> 00:05:05,000
|
| 531 |
+
who is responsible for giving this object?
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:05:05,000 --> 00:05:08,000
|
| 535 |
+
Mind you, we are working on the Spring Framework.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:05:08,000 --> 00:05:11,000
|
| 539 |
+
So when you specify the HttpServletRequest here,
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:05:11,000 --> 00:05:13,000
|
| 543 |
+
it is Spring's responsibility
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:05:13,000 --> 00:05:15,000
|
| 547 |
+
to assign you the object for this.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:05:15,000 --> 00:05:17,000
|
| 551 |
+
You just say, "I want this request object."
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:05:17,000 --> 00:05:18,000
|
| 555 |
+
Spring says, "Okay, done."
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:05:18,000 --> 00:05:20,000
|
| 559 |
+
Now once you have this object, you can get the values.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:05:20,000 --> 00:05:22,000
|
| 563 |
+
How will you get the values?
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:05:22,000 --> 00:05:24,000
|
| 567 |
+
You can say req.getParameter.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:05:24,000 --> 00:05:25,000
|
| 571 |
+
So that's the method you have to use
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:05:25,000 --> 00:05:27,000
|
| 575 |
+
to get the value from the request object.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:05:27,000 --> 00:05:28,000
|
| 579 |
+
Because, see, anyway,
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:05:28,000 --> 00:05:30,000
|
| 583 |
+
when a client sends a request to the server,
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:05:30,000 --> 00:05:31,000
|
| 587 |
+
the request object will have all the data.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:05:31,000 --> 00:05:33,000
|
| 591 |
+
So we just have to fetch the data.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:05:33,000 --> 00:05:34,000
|
| 595 |
+
So you have to say getParameter.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:05:34,000 --> 00:05:36,000
|
| 599 |
+
But for which value?
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:05:36,000 --> 00:05:39,000
|
| 603 |
+
In the browser, if you see, we have num1 and num2.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:05:39,000 --> 00:05:41,000
|
| 607 |
+
So we got two parameters.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:05:41,000 --> 00:05:45,000
|
| 611 |
+
I will say num1, but then this will be a type of String.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:05:45,000 --> 00:05:47,000
|
| 615 |
+
If you try to assign that to a variable.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:05:47,000 --> 00:05:49,000
|
| 619 |
+
So let's say you have int num1 here.
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:05:49,000 --> 00:05:51,000
|
| 623 |
+
So of course, this will not work
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:05:51,000 --> 00:05:53,000
|
| 627 |
+
because the getParameter returns a String.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:05:53,000 --> 00:05:54,000
|
| 631 |
+
So we have to basically convert this.
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:05:54,000 --> 00:05:57,000
|
| 635 |
+
You have to parse it with the Integer.parseInt.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:05:57,000 --> 00:05:58,000
|
| 639 |
+
That's done.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:05:58,000 --> 00:06:00,000
|
| 643 |
+
And we need this for the second variable as well.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:06:00,000 --> 00:06:02,000
|
| 647 |
+
So I will just copy this, paste it here,
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:06:02,000 --> 00:06:04,000
|
| 651 |
+
and this should be num2.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:06:04,000 --> 00:06:05,000
|
| 655 |
+
This should be num2.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:06:05,000 --> 00:06:08,000
|
| 659 |
+
Now, by doing this, we are getting the values,
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:06:08,000 --> 00:06:10,000
|
| 663 |
+
and then we just have to add them.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:06:10,000 --> 00:06:14,000
|
| 667 |
+
So I will say int result = num1 + num2.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:06:14,000 --> 00:06:16,000
|
| 671 |
+
Again, the logic can be anything, right?
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:06:16,000 --> 00:06:17,000
|
| 675 |
+
So whatever logic you have,
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:06:17,000 --> 00:06:19,000
|
| 679 |
+
you can write inside this method,
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:06:19,000 --> 00:06:21,000
|
| 683 |
+
and that's what we're doing here.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:06:21,000 --> 00:06:23,000
|
| 687 |
+
Once you've got this value, your job is done, right?
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:06:23,000 --> 00:06:26,000
|
| 691 |
+
You got the values, you are adding them.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:06:26,000 --> 00:06:29,000
|
| 695 |
+
At this point, I will just print the result in the console.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:06:29,000 --> 00:06:31,000
|
| 699 |
+
So here, this is where I want to print it.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:06:31,000 --> 00:06:32,000
|
| 703 |
+
So I will just restart this
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:06:32,000 --> 00:06:35,000
|
| 707 |
+
and see if I can actually get the values.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:06:35,000 --> 00:06:37,000
|
| 711 |
+
So I'll go back here and say "Submit."
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:06:37,000 --> 00:06:40,000
|
| 715 |
+
Okay, it says "Result is," but we are not printing it here;
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:06:40,000 --> 00:06:41,000
|
| 719 |
+
we are printing it on the console.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:06:41,000 --> 00:06:42,000
|
| 723 |
+
And the console says 13.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:06:42,000 --> 00:06:44,000
|
| 727 |
+
So 6 + 7 = 13, and it's working.
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:06:44,000 --> 00:06:46,000
|
| 731 |
+
But then I don't want to print on the console, right?
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:06:46,000 --> 00:06:48,000
|
| 735 |
+
I want to print it on the page.
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:06:48,000 --> 00:06:49,000
|
| 739 |
+
How will you do that?
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:06:49,000 --> 00:06:51,000
|
| 743 |
+
Let's see that in the next video.
|
| 744 |
+
|
12 - Spring Boot Web/012 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.12%20Accepting%20Data%20the%20servlet%20way
|
12 - Spring Boot Web/013 Display Data on Result Page_en.srt
ADDED
|
@@ -0,0 +1,540 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:02,000
|
| 3 |
+
(upbeat music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:02,000 --> 00:00:06,000
|
| 7 |
+
-: Okay, now we are printing the data on the console.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:09,000
|
| 11 |
+
We don't do that, we want to print this on the result page.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:09,000 --> 00:00:11,000
|
| 15 |
+
To do that, first of all,
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:11,000 --> 00:00:13,000
|
| 19 |
+
we have to send this data to the result page.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:13,000 --> 00:00:15,000
|
| 23 |
+
How will you do that, see, there are multiple ways
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:15,000 --> 00:00:17,000
|
| 27 |
+
of sending this data to the result page.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:17,000 --> 00:00:19,000
|
| 31 |
+
Of course, you cannot simply expect
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:19,000 --> 00:00:22,000
|
| 35 |
+
that this data will be available in this page.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:22,000 --> 00:00:24,000
|
| 39 |
+
You have to send it, there are multiple ways
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:24,000 --> 00:00:26,000
|
| 43 |
+
you can basically pass through the URL.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:26,000 --> 00:00:28,000
|
| 47 |
+
You can put a question mark here
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:28,000 --> 00:00:30,000
|
| 51 |
+
and you can say the result is this,
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:30,000 --> 00:00:33,000
|
| 55 |
+
or you can use something called session.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:33,000 --> 00:00:36,000
|
| 59 |
+
So in servlet, basically we have a concept of session.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:36,000 --> 00:00:38,000
|
| 63 |
+
I mean when I say servlet, it is also applicable for spring
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:38,000 --> 00:00:41,000
|
| 67 |
+
because behind the scene everything is servlet.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:41,000 --> 00:00:46,000
|
| 71 |
+
So we have to put the data in a session object.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:46,000 --> 00:00:48,000
|
| 75 |
+
Now what your session, so basically when you have multiple
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:48,000 --> 00:00:51,000
|
| 79 |
+
pages and if a user is accessing multiple pages,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:51,000 --> 00:00:55,000
|
| 83 |
+
you want to maintain this data between the pages.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:55,000 --> 00:00:57,000
|
| 87 |
+
And the way you can do that is with the help of session
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:57,000 --> 00:00:59,000
|
| 91 |
+
and to get the hold on a session,
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:59,000 --> 00:01:01,000
|
| 95 |
+
what you can do is you can just
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:01,000 --> 00:01:03,000
|
| 99 |
+
pass this session object here.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:03,000 --> 00:01:05,000
|
| 103 |
+
So you can create a HttpSession.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:07,000 --> 00:01:10,000
|
| 107 |
+
Now we just specify, so this is an interface.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:10,000 --> 00:01:12,000
|
| 111 |
+
If you click on HttpSession, this is an interface
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:12,000 --> 00:01:14,000
|
| 115 |
+
and we are creating a reference for it.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:14,000 --> 00:01:17,000
|
| 119 |
+
Now who is responsible to inject the object?
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:17,000 --> 00:01:18,000
|
| 123 |
+
You know it, spring framework.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:18,000 --> 00:01:22,000
|
| 127 |
+
Now with the object, I just have to add this data,
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:22,000 --> 00:01:25,000
|
| 131 |
+
visual data in the session.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:25,000 --> 00:01:28,000
|
| 135 |
+
So the way you can do that is by saying session dot.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:28,000 --> 00:01:31,000
|
| 139 |
+
So it has a method called set attribute.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:31,000 --> 00:01:32,000
|
| 143 |
+
And in this you have to pass two things.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:32,000 --> 00:01:35,000
|
| 147 |
+
The name of a variable or name of the data, which result,
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:35,000 --> 00:01:38,000
|
| 151 |
+
and the actual data which is result.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:38,000 --> 00:01:40,000
|
| 155 |
+
So basically you have to do, you have to pass two things.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:40,000 --> 00:01:43,000
|
| 159 |
+
One is the name and second is the data.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:43,000 --> 00:01:46,000
|
| 163 |
+
So name is result and the data is result,
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:46,000 --> 00:01:47,000
|
| 167 |
+
which is the value in this case.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:47,000 --> 00:01:51,000
|
| 171 |
+
And that's it, so when you call result JSP,
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:51,000 --> 00:01:52,000
|
| 175 |
+
and see we talked about it, right?
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:52,000 --> 00:01:56,000
|
| 179 |
+
So when you call add, the dispatcher is calling result JSP.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:56,000 --> 00:01:58,000
|
| 183 |
+
So that means that there's two different pages.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:58,000 --> 00:02:00,000
|
| 187 |
+
So we have to maintain this data.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:02:00,000 --> 00:02:03,000
|
| 191 |
+
The way we can do that is with help of session.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:02:03,000 --> 00:02:06,000
|
| 195 |
+
So we are adding this data in the session object.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:02:06,000 --> 00:02:09,000
|
| 199 |
+
Okay, we have done that right now, we have added it.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:09,000 --> 00:02:11,000
|
| 203 |
+
How will you get this data in the result page?
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:11,000 --> 00:02:14,000
|
| 207 |
+
Now that's tricky, so what you can do is here,
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:14,000 --> 00:02:17,000
|
| 211 |
+
you can print, in fact you can print it here itself.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:17,000 --> 00:02:21,000
|
| 215 |
+
You can print the data, you can simply say result,
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:21,000 --> 00:02:22,000
|
| 219 |
+
but will it work?
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:22,000 --> 00:02:24,000
|
| 223 |
+
Of course not, right, this look like a normal text.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:24,000 --> 00:02:28,000
|
| 227 |
+
How will your JSP knows that this is not a simple text.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:28,000 --> 00:02:30,000
|
| 231 |
+
This is actually a variable.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:30,000 --> 00:02:33,000
|
| 235 |
+
And to do that we have to make sure that we put
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:33,000 --> 00:02:36,000
|
| 239 |
+
that into JSP code.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:36,000 --> 00:02:39,000
|
| 243 |
+
So whenever you want to write a Java code inside JSP,
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:39,000 --> 00:02:40,000
|
| 247 |
+
you have to open the angular bracket.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:40,000 --> 00:02:42,000
|
| 251 |
+
Then percentage, then percentage, angular bracket.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:42,000 --> 00:02:43,000
|
| 255 |
+
This is how we write the Java code.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:43,000 --> 00:02:46,000
|
| 259 |
+
Now in between you can write whatever code you want
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:46,000 --> 00:02:48,000
|
| 263 |
+
and we don't want any code.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:48,000 --> 00:02:52,000
|
| 267 |
+
What we want is we have to say session get attribute.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:52,000 --> 00:02:54,000
|
| 271 |
+
And in bracket you have to mention the name
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:54,000 --> 00:02:55,000
|
| 275 |
+
of a variable which is result here.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:55,000 --> 00:02:57,000
|
| 279 |
+
So we have to say session get attribute
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:57,000 --> 00:03:00,000
|
| 283 |
+
and name of our variable
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:03:00,000 --> 00:03:02,000
|
| 287 |
+
or the name of the data which result in this case.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:03:02,000 --> 00:03:04,000
|
| 291 |
+
Now the question arise, how will you get this session?
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:03:04,000 --> 00:03:05,000
|
| 295 |
+
Object because in servlet
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:03:05,000 --> 00:03:08,000
|
| 299 |
+
or here we are injecting the object right?
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:08,000 --> 00:03:10,000
|
| 303 |
+
Now that's the beauty about JSP.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:10,000 --> 00:03:12,000
|
| 307 |
+
JSP gives you this object by default.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:12,000 --> 00:03:14,000
|
| 311 |
+
So you don't have to create this object.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:14,000 --> 00:03:16,000
|
| 315 |
+
JSP says, session is yours, request is yours.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:16,000 --> 00:03:19,000
|
| 319 |
+
You just use the object, it's available behind the scene.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:19,000 --> 00:03:21,000
|
| 323 |
+
So we got a session object, we are saying get attribute
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:21,000 --> 00:03:25,000
|
| 327 |
+
and we are printing or we are getting the data of result.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:25,000 --> 00:03:27,000
|
| 331 |
+
And that's what you're going to display on the page.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:27,000 --> 00:03:30,000
|
| 335 |
+
And now let's see if this works, let's read on this.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:30,000 --> 00:03:31,000
|
| 339 |
+
Go back to your browser
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:31,000 --> 00:03:33,000
|
| 343 |
+
and I will just refresh this
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:33,000 --> 00:03:38,000
|
| 347 |
+
with a different value this time, let's say 7 and 88.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:38,000 --> 00:03:41,000
|
| 351 |
+
Let's click on submit and we got an error.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:41,000 --> 00:03:44,000
|
| 355 |
+
The error is internal servlet error 500.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:44,000 --> 00:03:49,000
|
| 359 |
+
Let's see what happened here, and I love errors.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:49,000 --> 00:03:50,000
|
| 363 |
+
Okay, one thing I forgot.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:50,000 --> 00:03:53,000
|
| 367 |
+
It's just that when you, I mean you can write the code here,
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:53,000 --> 00:03:55,000
|
| 371 |
+
but then when you want the value of it,
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:55,000 --> 00:03:56,000
|
| 375 |
+
you have to put the equal to as well
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:56,000 --> 00:03:58,000
|
| 379 |
+
because we directly want to get this value
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:58,000 --> 00:04:00,000
|
| 383 |
+
and print it on the page.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:04:00,000 --> 00:04:03,000
|
| 387 |
+
I forgot to put the equal to symbol
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:04:05,000 --> 00:04:07,000
|
| 391 |
+
now I hope it'll work.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:04:07,000 --> 00:04:12,000
|
| 395 |
+
Let's go back to the browser, say refresh.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:04:12,000 --> 00:04:14,000
|
| 399 |
+
And you can see we got the value, which is 95.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:04:14,000 --> 00:04:16,000
|
| 403 |
+
So that's how basically you can get the value, okay?
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:04:16,000 --> 00:04:18,000
|
| 407 |
+
So we can use a session object to get the value.
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:04:18,000 --> 00:04:20,000
|
| 411 |
+
There's one way, there's another way
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:20,000 --> 00:04:22,000
|
| 415 |
+
where you can use the JSTL way.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:22,000 --> 00:04:25,000
|
| 419 |
+
JSTL is basically a JSP standard library
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:25,000 --> 00:04:27,000
|
| 423 |
+
or template library, which allows you
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:27,000 --> 00:04:30,000
|
| 427 |
+
to directly use some certain tags,
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:30,000 --> 00:04:31,000
|
| 431 |
+
which you can get the value.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:31,000 --> 00:04:34,000
|
| 435 |
+
So we can just put the currently packets here
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:34,000 --> 00:04:35,000
|
| 439 |
+
and we can remove everything.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:35,000 --> 00:04:37,000
|
| 443 |
+
And you can simply put result.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:37,000 --> 00:04:38,000
|
| 447 |
+
So it'll directly use,
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:38,000 --> 00:04:41,000
|
| 451 |
+
it'll directly search this session object,
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:41,000 --> 00:04:42,000
|
| 455 |
+
request object to get your data.
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:42,000 --> 00:04:44,000
|
| 459 |
+
And if you have, it'll directly fetch it.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:44,000 --> 00:04:47,000
|
| 463 |
+
The only thing is you have to put the dollar symbol as well
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:47,000 --> 00:04:50,000
|
| 467 |
+
by specifying, hey, this is not a normal curly packet,
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:50,000 --> 00:04:51,000
|
| 471 |
+
this is a JSTL.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:51,000 --> 00:04:54,000
|
| 475 |
+
So you have to use the dollar symbol and the current package
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:54,000 --> 00:04:55,000
|
| 479 |
+
and then you have to set result.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:55,000 --> 00:04:59,000
|
| 483 |
+
Now if you run this, let's see if it is changing something,
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:04:59,000 --> 00:05:02,000
|
| 487 |
+
let's refresh the servlet is not started yet.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:05:02,000 --> 00:05:04,000
|
| 491 |
+
Refresh and it works.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:05:04,000 --> 00:05:07,000
|
| 495 |
+
So basically you have both the ways you can use the normal
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:05:07,000 --> 00:05:11,000
|
| 499 |
+
JSP syntax or you can use the JSTL.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:05:11,000 --> 00:05:13,000
|
| 503 |
+
But this is how basically you can pass the value
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:05:13,000 --> 00:05:16,000
|
| 507 |
+
between the JSP or between the servlets.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:05:16,000 --> 00:05:20,000
|
| 511 |
+
Because ultimately JSP will get converted into servlets.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:05:20,000 --> 00:05:22,000
|
| 515 |
+
But one thing here, I mean this works,
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:05:22,000 --> 00:05:23,000
|
| 519 |
+
but it doesn't look good.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:05:23,000 --> 00:05:26,000
|
| 523 |
+
We are working on spring framework, right?
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:05:26,000 --> 00:05:29,000
|
| 527 |
+
This is okay, but can you just simplify this?
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:05:29,000 --> 00:05:32,000
|
| 531 |
+
And that's the beauty about spring, right?
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:05:32,000 --> 00:05:34,000
|
| 535 |
+
Can we simplify this code, of course we can.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:05:34,000 --> 00:05:37,000
|
| 539 |
+
And let's see that in the next video.
|
| 540 |
+
|
12 - Spring Boot Web/013 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.13%20Display%20Data%20on%20Result%20Page
|
12 - Spring Boot Web/014 RequestParam_en.srt
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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+
Now, as I mentioned before,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:10,000
|
| 15 |
+
this is a sublet way of doing things, right?
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:10,000 --> 00:00:12,000
|
| 19 |
+
Where you have to handle the request,
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:12,000 --> 00:00:13,000
|
| 23 |
+
you have to create a sessional object,
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:13,000 --> 00:00:16,000
|
| 27 |
+
but now in spring it'll make it bit easy.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:16,000 --> 00:00:20,000
|
| 31 |
+
How? See if we talk about this ad, which is a path, right?
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:20,000 --> 00:00:23,000
|
| 35 |
+
So in the browser you can see it says there's an ad request
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:23,000 --> 00:00:28,000
|
| 39 |
+
and then you are sending this two data in the URL itself.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:28,000 --> 00:00:31,000
|
| 43 |
+
So when you're sending this data here as a query parameter,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:31,000 --> 00:00:33,000
|
| 47 |
+
what we can also do is instead
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:33,000 --> 00:00:36,000
|
| 51 |
+
of using this request object, we can delete this.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:36,000 --> 00:00:40,000
|
| 55 |
+
What if you can just take those two values in two variables?
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:40,000 --> 00:00:42,000
|
| 59 |
+
Something like this,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:42,000 --> 00:00:46,000
|
| 63 |
+
You can simply say, int num1, int num2.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:46,000 --> 00:00:49,000
|
| 67 |
+
And what I'm expecting is it'll directly give
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:49,000 --> 00:00:51,000
|
| 71 |
+
those values to these variables.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:51,000 --> 00:00:53,000
|
| 75 |
+
The question is, will it really work?
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:53,000 --> 00:00:55,000
|
| 79 |
+
We'll do that in, we'll check that in some time,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:55,000 --> 00:00:57,000
|
| 83 |
+
but that also means that when you use
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:57,000 --> 00:00:59,000
|
| 87 |
+
these two variables here,
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:59,000 --> 00:01:00,000
|
| 91 |
+
then we don't have
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:01:00,000 --> 00:01:03,000
|
| 95 |
+
to get the data like this from the request object.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:03,000 --> 00:01:04,000
|
| 99 |
+
Let's remember this.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:04,000 --> 00:01:06,000
|
| 103 |
+
So if we can get those data here,
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:06,000 --> 00:01:08,000
|
| 107 |
+
we don't have to manually get the data, right?
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:08,000 --> 00:01:11,000
|
| 111 |
+
We can simply say num1 + num2,
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:11,000 --> 00:01:13,000
|
| 115 |
+
and then we can save that in result.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:13,000 --> 00:01:15,000
|
| 119 |
+
But will it work? Let's try.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:15,000 --> 00:01:17,000
|
| 123 |
+
So let me relaunch this application,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:17,000 --> 00:01:19,000
|
| 127 |
+
okay, application restarted.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:19,000 --> 00:01:21,000
|
| 131 |
+
Let's go back to the browser
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:21,000 --> 00:01:25,000
|
| 135 |
+
and, okay, now this page, I want to go for the homepage
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:25,000 --> 00:01:26,000
|
| 139 |
+
and here let me enter to values.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:26,000 --> 00:01:28,000
|
| 143 |
+
I will say 7 + 8.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:28,000 --> 00:01:31,000
|
| 147 |
+
If I click on submit, it works.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:31,000 --> 00:01:32,000
|
| 151 |
+
I mean that's weird, right?
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:32,000 --> 00:01:34,000
|
| 155 |
+
Is this code really working?
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:34,000 --> 00:01:37,000
|
| 159 |
+
What I would also do is let me just add a extra number here
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:37,000 --> 00:01:39,000
|
| 163 |
+
just to verify.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:39,000 --> 00:01:41,000
|
| 167 |
+
If it works, then of course, right?
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:41,000 --> 00:01:44,000
|
| 171 |
+
This is much better than the earlier code.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:44,000 --> 00:01:46,000
|
| 175 |
+
Let's go back, submit, and you can see we got 16.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:46,000 --> 00:01:48,000
|
| 179 |
+
So yes, this is working.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:48,000 --> 00:01:49,000
|
| 183 |
+
Now how it is working.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:49,000 --> 00:01:52,000
|
| 187 |
+
So what happens is when you send a request
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:52,000 --> 00:01:53,000
|
| 191 |
+
for the ad method
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:53,000 --> 00:01:56,000
|
| 195 |
+
and you're passing your those two query parameters
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:56,000 --> 00:02:00,000
|
| 199 |
+
with the same name, they got the name num1 and num2,
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:00,000 --> 00:02:01,000
|
| 203 |
+
and that's why it is working.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:01,000 --> 00:02:03,000
|
| 207 |
+
There is also one thing you can...
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:03,000 --> 00:02:05,000
|
| 211 |
+
What if you want to have a different variable name.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:05,000 --> 00:02:07,000
|
| 215 |
+
Let's say you don't have num1 here we just have num.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:07,000 --> 00:02:10,000
|
| 219 |
+
And here also I'm using num, I'm not using num1 now.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:10,000 --> 00:02:12,000
|
| 223 |
+
Will this work with a different name?
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:12,000 --> 00:02:15,000
|
| 227 |
+
Let's try and go back here, say refresh
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:15,000 --> 00:02:19,000
|
| 231 |
+
and let's hit it with different values and say submit.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:19,000 --> 00:02:22,000
|
| 235 |
+
Okay, so you can see we got an error, which is 500.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:22,000 --> 00:02:24,000
|
| 239 |
+
Reason for this is it is not able
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:24,000 --> 00:02:26,000
|
| 243 |
+
to match the variable name.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:26,000 --> 00:02:29,000
|
| 247 |
+
Let me just search for the reason.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:29,000 --> 00:02:32,000
|
| 251 |
+
It says optional int parameter num is present
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:32,000 --> 00:02:34,000
|
| 255 |
+
but cannot be translated into a null value.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:34,000 --> 00:02:36,000
|
| 259 |
+
Okay, so this is optional, right?
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:36,000 --> 00:02:38,000
|
| 263 |
+
Which is we are getting off this variable
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:38,000 --> 00:02:41,000
|
| 267 |
+
and it's not matching with the data which we are sending.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:41,000 --> 00:02:43,000
|
| 271 |
+
So this by default it is null.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:43,000 --> 00:02:45,000
|
| 275 |
+
So we have to make sure it is num1.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:45,000 --> 00:02:47,000
|
| 279 |
+
But what if you don't want to give num1 there?
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:47,000 --> 00:02:49,000
|
| 283 |
+
So in that case you can use
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:49,000 --> 00:02:52,000
|
| 287 |
+
a annotation called RequestParam.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:53,000 --> 00:02:56,000
|
| 291 |
+
And in this bracket you can mention the actual variable
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:56,000 --> 00:02:59,000
|
| 295 |
+
or actual name which is coming from the browser.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:59,000 --> 00:03:01,000
|
| 299 |
+
So in the URL, we are sending num1.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:01,000 --> 00:03:03,000
|
| 303 |
+
So what we are saying is
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:03,000 --> 00:03:05,000
|
| 307 |
+
whatever data you are getting in num1,
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:05,000 --> 00:03:08,000
|
| 311 |
+
just assign to that variable called num
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:08,000 --> 00:03:09,000
|
| 315 |
+
and that's how you can do it.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:09,000 --> 00:03:12,000
|
| 319 |
+
So again, it is optional if you have a same variable name,
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:12,000 --> 00:03:14,000
|
| 323 |
+
but it's better to write it
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:14,000 --> 00:03:16,000
|
| 327 |
+
so it go back to the same variable.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:16,000 --> 00:03:19,000
|
| 331 |
+
And same you can apply here.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:19,000 --> 00:03:21,000
|
| 335 |
+
So we can say request, not request mapping.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:21,000 --> 00:03:22,000
|
| 339 |
+
RequestParam.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:27,000 --> 00:03:29,000
|
| 343 |
+
And here we can say this is for num2.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:30,000 --> 00:03:32,000
|
| 347 |
+
And even if you say they are same,
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:32,000 --> 00:03:34,000
|
| 351 |
+
you can skip this name here
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:34,000 --> 00:03:37,000
|
| 355 |
+
and you can keep it just RequestParam and that works.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:37,000 --> 00:03:40,000
|
| 359 |
+
So basically if you can directly get the value from the URL,
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:40,000 --> 00:03:44,000
|
| 363 |
+
you don't have to use the CDP server request object.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:44,000 --> 00:03:46,000
|
| 367 |
+
And that's how basically you work with Param.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:46,000 --> 00:03:48,000
|
| 371 |
+
Let's again, for the last time,
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:48,000 --> 00:03:50,000
|
| 375 |
+
let's run this for this particular video.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:50,000 --> 00:03:52,000
|
| 379 |
+
So let's go back to the browser.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:52,000 --> 00:03:56,000
|
| 383 |
+
Let's refresh this, of course with different values
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:56,000 --> 00:03:58,000
|
| 387 |
+
and it works, okay?
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:58,000 --> 00:04:00,000
|
| 391 |
+
So if we got this extra one
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:04:00,000 --> 00:04:02,000
|
| 395 |
+
because of this extra edition we are doing,
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:04:02,000 --> 00:04:04,000
|
| 399 |
+
but yeah, that's how you basically use RequestParam
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:04:04,000 --> 00:04:08,000
|
| 403 |
+
so that you can simplify your code much more.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:04:08,000 --> 00:04:09,000
|
| 407 |
+
Now what else?
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:04:09,000 --> 00:04:12,000
|
| 411 |
+
See we have removed the CDP request object, right?
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:12,000 --> 00:04:14,000
|
| 415 |
+
Or the CDP server request object.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:14,000 --> 00:04:15,000
|
| 419 |
+
How about this sessional object?
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:15,000 --> 00:04:17,000
|
| 423 |
+
I don't want to work with sessional object.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:17,000 --> 00:04:21,000
|
| 427 |
+
How can we remove that? So let's see that in the next video.
|
| 428 |
+
|
12 - Spring Boot Web/014 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.14%20RequestParam
|
12 - Spring Boot Web/015 Model Object_en.srt
ADDED
|
@@ -0,0 +1,396 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(bright music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:04,000
|
| 7 |
+
-: So now it's time to get rid
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:04,000 --> 00:00:07,000
|
| 11 |
+
of this HTTP session object here.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:08,000
|
| 15 |
+
So before we do that, let's verify
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:08,000 --> 00:00:10,000
|
| 19 |
+
what we are doing in results.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:10,000 --> 00:00:13,000
|
| 23 |
+
So basically here we are printing the result is,
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:13,000 --> 00:00:15,000
|
| 27 |
+
and then we have used JSTL here just
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:15,000 --> 00:00:18,000
|
| 31 |
+
to fetch the value of that particular data,
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:18,000 --> 00:00:20,000
|
| 35 |
+
which is result in this case.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:20,000 --> 00:00:22,000
|
| 39 |
+
So when we talked about MVC, we had a model view controller,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:22,000 --> 00:00:24,000
|
| 43 |
+
right, where controller is responsible
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:24,000 --> 00:00:26,000
|
| 47 |
+
to accept the user request, right?
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:26,000 --> 00:00:28,000
|
| 51 |
+
So we've got a controller here
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:28,000 --> 00:00:31,000
|
| 55 |
+
and then we have a view which is going to decline.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:31,000 --> 00:00:33,000
|
| 59 |
+
So we have talked about the controller and the view.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:33,000 --> 00:00:35,000
|
| 63 |
+
What about that data?
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:35,000 --> 00:00:37,000
|
| 67 |
+
Remember we have talked about how do you transfer data
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:37,000 --> 00:00:41,000
|
| 71 |
+
between the controller and the view?
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:41,000 --> 00:00:43,000
|
| 75 |
+
So basically we have to use an object
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:43,000 --> 00:00:45,000
|
| 79 |
+
and that is your model object.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:45,000 --> 00:00:46,000
|
| 83 |
+
And we are not using it here.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:46,000 --> 00:00:48,000
|
| 87 |
+
So instead of using session, I want to use
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:48,000 --> 00:00:51,000
|
| 91 |
+
that model object and how do we use that?
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:51,000 --> 00:00:53,000
|
| 95 |
+
As the name suggest, we can simply say, model,
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:53,000 --> 00:00:57,000
|
| 99 |
+
let's input the package for this and say model.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:57,000 --> 00:00:59,000
|
| 103 |
+
That's it. You just get this model.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:59,000 --> 00:01:02,000
|
| 107 |
+
And now with this model object, instead
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:02,000 --> 00:01:04,000
|
| 111 |
+
of using session, let me delete that.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:04,000 --> 00:01:07,000
|
| 115 |
+
I can simply say model.addAttribute.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:08,000 --> 00:01:10,000
|
| 119 |
+
So instead of said attribute, we have add attribute
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:10,000 --> 00:01:13,000
|
| 123 |
+
because we can add multiple attributes, not just one.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:13,000 --> 00:01:15,000
|
| 127 |
+
And then we can give a name
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:15,000 --> 00:01:16,000
|
| 131 |
+
the same way we have done before.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:16,000 --> 00:01:19,000
|
| 135 |
+
We can say result and we can say result.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:19,000 --> 00:01:21,000
|
| 139 |
+
Okay, and what is this model?
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:21,000 --> 00:01:23,000
|
| 143 |
+
So basically model is interface,
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:23,000 --> 00:01:27,000
|
| 147 |
+
which was introduced in 2.5 version of Spring.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:27,000 --> 00:01:32,000
|
| 151 |
+
It is basically used to transfer data between the things.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:32,000 --> 00:01:35,000
|
| 155 |
+
I just want to make sure I've imported the right package.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:35,000 --> 00:01:37,000
|
| 159 |
+
Yeah, so if you want to transfer between controller
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:37,000 --> 00:01:40,000
|
| 163 |
+
and the JSP, we have to use something called model here.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:40,000 --> 00:01:43,000
|
| 167 |
+
Now, once we've got model, we just have to add attribute,
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:43,000 --> 00:01:45,000
|
| 171 |
+
and let's see if this works.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:45,000 --> 00:01:46,000
|
| 175 |
+
Let's restart the application.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:46,000 --> 00:01:47,000
|
| 179 |
+
So now we are not using a HTTP session.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:47,000 --> 00:01:50,000
|
| 183 |
+
We are basically using a model.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:50,000 --> 00:01:55,000
|
| 187 |
+
And if you go back to your browser, let's go back here,
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:55,000 --> 00:01:56,000
|
| 191 |
+
refresh
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:57,000 --> 00:02:02,000
|
| 195 |
+
and say some big number, enter, and you've got the output.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:02:02,000 --> 00:02:05,000
|
| 199 |
+
Doesn't matter what the output is, but we got the output.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:05,000 --> 00:02:08,000
|
| 203 |
+
So that's how basically your model object works.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:08,000 --> 00:02:09,000
|
| 207 |
+
So instead of using SGP session, we are using model now.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:12,000 --> 00:02:16,000
|
| 211 |
+
Okay, so we have get, we got rid of the the request object.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:16,000 --> 00:02:18,000
|
| 215 |
+
We got rid of the HTTP session.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:18,000 --> 00:02:20,000
|
| 219 |
+
Now, this is how basically you build
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:21,000 --> 00:02:22,000
|
| 223 |
+
application using spring NVC or spring.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:22,000 --> 00:02:24,000
|
| 227 |
+
Spring Boot.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:24,000 --> 00:02:27,000
|
| 231 |
+
You can say, okay, but also I want to change one more thing.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:27,000 --> 00:02:28,000
|
| 235 |
+
I know you'll be saying,
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:28,000 --> 00:02:30,000
|
| 239 |
+
Hey, how many things you're changing?
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:30,000 --> 00:02:33,000
|
| 243 |
+
Okay, let, let me do one last, I hope.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:33,000 --> 00:02:35,000
|
| 247 |
+
I just want
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:35,000 --> 00:02:36,000
|
| 251 |
+
to get rid of this JSP page.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:36,000 --> 00:02:39,000
|
| 255 |
+
I mean not JSP page, but .JSP. I mean, think about this.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:39,000 --> 00:02:41,000
|
| 259 |
+
Remember when we talked about MVC, I said
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:41,000 --> 00:02:44,000
|
| 263 |
+
for the view we have multiple options.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:44,000 --> 00:02:49,000
|
| 267 |
+
We got JSP, we got free marker, we got theme leaf.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:49,000 --> 00:02:50,000
|
| 271 |
+
So we have so many options, right?
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:50,000 --> 00:02:55,000
|
| 275 |
+
And let's say one day I decided to move from let's say, JSP
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:55,000 --> 00:02:56,000
|
| 279 |
+
to theme leaf.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:56,000 --> 00:03:00,000
|
| 283 |
+
In that case you will have to go to each controller
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:03:00,000 --> 00:03:02,000
|
| 287 |
+
and check where, where are we using this
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:03:02,000 --> 00:03:04,000
|
| 291 |
+
dot JSP extension.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:03:04,000 --> 00:03:07,000
|
| 295 |
+
So if you can get rid of this, will it still work?
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:03:07,000 --> 00:03:10,000
|
| 299 |
+
Of course, we have to change both the side.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:10,000 --> 00:03:13,000
|
| 303 |
+
Nowhere. I want to mention the extension.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:13,000 --> 00:03:14,000
|
| 307 |
+
That's one.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:14,000 --> 00:03:18,000
|
| 311 |
+
Next, maybe I want to keep my files,
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:18,000 --> 00:03:21,000
|
| 315 |
+
the web files, not in the web app folder,
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:21,000 --> 00:03:22,000
|
| 319 |
+
but it's, but somewhere else.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:22,000 --> 00:03:24,000
|
| 323 |
+
Maybe I, I have a new view folder here.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:24,000 --> 00:03:25,000
|
| 327 |
+
So I will just right click here
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:25,000 --> 00:03:30,000
|
| 331 |
+
and say I have a folder called views
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:30,000 --> 00:03:33,000
|
| 335 |
+
and I want to move this things
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:34,000 --> 00:03:35,000
|
| 339 |
+
inside this.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:36,000 --> 00:03:37,000
|
| 343 |
+
Now question arise.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:37,000 --> 00:03:39,000
|
| 347 |
+
After making these changes, will it work?
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:39,000 --> 00:03:40,000
|
| 351 |
+
Let's try.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:40,000 --> 00:03:42,000
|
| 355 |
+
So I'll restart the application
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:42,000 --> 00:03:43,000
|
| 359 |
+
and if I go back to the browser now,
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:43,000 --> 00:03:46,000
|
| 363 |
+
let's say refresh the homepage.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:46,000 --> 00:03:47,000
|
| 367 |
+
And even the homepage,
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:47,000 --> 00:03:49,000
|
| 371 |
+
you can see the url, I'm calling the homepage.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:49,000 --> 00:03:51,000
|
| 375 |
+
It's not able to find the homepage.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:51,000 --> 00:03:53,000
|
| 379 |
+
Why? The homepage is there.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:53,000 --> 00:03:55,000
|
| 383 |
+
It's just that it in different folder plus
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:55,000 --> 00:03:58,000
|
| 387 |
+
we are not even specifying the extension.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:58,000 --> 00:04:01,000
|
| 391 |
+
So how do we solve this problem?
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:04:01,000 --> 00:04:03,000
|
| 395 |
+
Let's talk about that in the next video.
|
| 396 |
+
|
12 - Spring Boot Web/015 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.15%20Model%20Object
|
12 - Spring Boot Web/016 Setting Prefix and Suffix_en.srt
ADDED
|
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(light music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:04,000
|
| 7 |
+
-: Okay, so let's solve this problem.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:04,000 --> 00:00:07,000
|
| 11 |
+
So basically now, our views, which are the jsp files,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:09,000
|
| 15 |
+
are in other folder.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:09,000 --> 00:00:12,000
|
| 19 |
+
Additionally, we have changed the name of the view
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:12,000 --> 00:00:15,000
|
| 23 |
+
directly with the name of the view, not with the extension.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:15,000 --> 00:00:17,000
|
| 27 |
+
So the question arise, how would you solve it?
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:17,000 --> 00:00:20,000
|
| 31 |
+
The thing is, when you talk about your spring framework,
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:20,000 --> 00:00:23,000
|
| 35 |
+
it also has a view resolver.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:23,000 --> 00:00:24,000
|
| 39 |
+
So basically, behind the scenes,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:24,000 --> 00:00:27,000
|
| 43 |
+
whenever you return a particular jsp file or something,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:27,000 --> 00:00:29,000
|
| 47 |
+
when you return a name here,
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:29,000 --> 00:00:31,000
|
| 51 |
+
and if you see we are running a string,
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:31,000 --> 00:00:33,000
|
| 55 |
+
so someone has to map it, right?
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:33,000 --> 00:00:36,000
|
| 59 |
+
So there's also a component which helps you to resolve this
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:36,000 --> 00:00:39,000
|
| 63 |
+
and that is called a view resolver.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:39,000 --> 00:00:42,000
|
| 67 |
+
So when you say, "Hey, I'm returning result here."
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:42,000 --> 00:00:44,000
|
| 71 |
+
Now view resolver has no idea,
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:44,000 --> 00:00:46,000
|
| 75 |
+
first of all, where this file is,
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:46,000 --> 00:00:48,000
|
| 79 |
+
and next what is the extension.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:48,000 --> 00:00:50,000
|
| 83 |
+
So we can talk to view resolver by saying,
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:50,000 --> 00:00:51,000
|
| 87 |
+
"Hey, don't worry,
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:51,000 --> 00:00:53,000
|
| 91 |
+
let me tell you where will you find it
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:53,000 --> 00:00:55,000
|
| 95 |
+
and what is the extension."
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:55,000 --> 00:00:57,000
|
| 99 |
+
And the way you can do that,
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:57,000 --> 00:00:58,000
|
| 103 |
+
is with the help of a property file.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:58,000 --> 00:01:00,000
|
| 107 |
+
Of course, we are conferring something, right?
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:00,000 --> 00:01:03,000
|
| 111 |
+
And when you configure your spring framework,
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:03,000 --> 00:01:05,000
|
| 115 |
+
spring boot basically gives you this amazing file
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:05,000 --> 00:01:07,000
|
| 119 |
+
called application of properties.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:07,000 --> 00:01:10,000
|
| 123 |
+
This is where you can mention the properties,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:10,000 --> 00:01:12,000
|
| 127 |
+
but we don't know which property, right?
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:12,000 --> 00:01:15,000
|
| 131 |
+
So for that, again, you don't have to buy hard disk,
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:15,000 --> 00:01:16,000
|
| 135 |
+
the moment, the more you work,
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:16,000 --> 00:01:19,000
|
| 139 |
+
the more you will remember the property names.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:19,000 --> 00:01:21,000
|
| 143 |
+
But if you search for spring application properties,
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:21,000 --> 00:01:24,000
|
| 147 |
+
the first link here, the common application properties,
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:24,000 --> 00:01:27,000
|
| 151 |
+
if you go there, there are so many properties you can set
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:27,000 --> 00:01:29,000
|
| 155 |
+
to configure your application, okay?
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:29,000 --> 00:01:30,000
|
| 159 |
+
Don't get stressed with this.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:30,000 --> 00:01:33,000
|
| 163 |
+
It's not, we don't have to remember everything.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:33,000 --> 00:01:36,000
|
| 167 |
+
Few of them we will be using most of the time.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:36,000 --> 00:01:38,000
|
| 171 |
+
And even if you don't remember anything,
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:38,000 --> 00:01:39,000
|
| 175 |
+
you can just Google it.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:39,000 --> 00:01:40,000
|
| 179 |
+
Stackoverflow is there.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:40,000 --> 00:01:41,000
|
| 183 |
+
AI is there.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:41,000 --> 00:01:44,000
|
| 187 |
+
AI tools are available, they will give you the exact name.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:44,000 --> 00:01:45,000
|
| 191 |
+
But here what I will do
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:45,000 --> 00:01:48,000
|
| 195 |
+
is I will search for the MVC property.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:48,000 --> 00:01:51,000
|
| 199 |
+
And in this MVC, we have to set the location
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:51,000 --> 00:01:53,000
|
| 203 |
+
and we have to set the extension, right?
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:53,000 --> 00:01:56,000
|
| 207 |
+
So the location is your prefix.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:56,000 --> 00:01:59,000
|
| 211 |
+
So the name, result, so prefix is the views
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:59,000 --> 00:02:03,000
|
| 215 |
+
and the postfix is the extension, which is .jsp, okay?
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:03,000 --> 00:02:05,000
|
| 219 |
+
And then we can search
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:05,000 --> 00:02:08,000
|
| 223 |
+
for something called prefix and postfix.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:08,000 --> 00:02:10,000
|
| 227 |
+
So if you can see, not prefix and postfix,
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:10,000 --> 00:02:12,000
|
| 231 |
+
prefix and suffix.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:12,000 --> 00:02:14,000
|
| 235 |
+
These are the properties we have to mention, okay?
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:14,000 --> 00:02:16,000
|
| 239 |
+
So example, if you set the prefix,
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:16,000 --> 00:02:18,000
|
| 243 |
+
let me just copy this.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:18,000 --> 00:02:22,000
|
| 247 |
+
So prefix, you have to set slash, views, slash,
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:22,000 --> 00:02:24,000
|
| 251 |
+
that's the folder name.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:24,000 --> 00:02:26,000
|
| 255 |
+
And then we have to set this suffix as well.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:26,000 --> 00:02:29,000
|
| 259 |
+
And this is your extension, which is .jsp, that's it.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:29,000 --> 00:02:31,000
|
| 263 |
+
This, you have to mention these two things.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:31,000 --> 00:02:32,000
|
| 267 |
+
So what we are doing is we are specifying the prefix
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:32,000 --> 00:02:36,000
|
| 271 |
+
and we are specifying the suffix, which is the extension.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:36,000 --> 00:02:38,000
|
| 275 |
+
Let's restart the application now.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:38,000 --> 00:02:39,000
|
| 279 |
+
I hope this will work.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:39,000 --> 00:02:41,000
|
| 283 |
+
Let's go back to your browser.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:41,000 --> 00:02:44,000
|
| 287 |
+
This page, let me just close the property files.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:44,000 --> 00:02:49,000
|
| 291 |
+
And now, if I go to localhost:8080,
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:50,000 --> 00:02:52,000
|
| 295 |
+
okay, it's not,
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:52,000 --> 00:02:54,000
|
| 299 |
+
it's not running the CSS.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:54,000 --> 00:02:56,000
|
| 303 |
+
Let me reload my entire IntelliJ Idea.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:02:56,000 --> 00:02:57,000
|
| 307 |
+
Let's run this now.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:02:57,000 --> 00:02:59,000
|
| 311 |
+
Okay, go back to your browser, reload.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:02:59,000 --> 00:03:02,000
|
| 315 |
+
Okay, some issue with the CSS, we will resolve that later.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:02,000 --> 00:03:04,000
|
| 319 |
+
And let me just try the values.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:04,000 --> 00:03:05,000
|
| 323 |
+
Click on submit.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:05,000 --> 00:03:06,000
|
| 327 |
+
And you can see it worked.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:06,000 --> 00:03:09,000
|
| 331 |
+
We got result is 13.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:09,000 --> 00:03:10,000
|
| 335 |
+
So basically it was able to find the view,
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:10,000 --> 00:03:13,000
|
| 339 |
+
it was able to find the JSP as well.
|
| 340 |
+
|
12 - Spring Boot Web/016 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.16%20Setting%20Prefix%20and%20Suffix
|
12 - Spring Boot Web/017 ModelAndView_en.srt
ADDED
|
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: Now in this video, we'll talk about ModelAndView.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:08,000
|
| 11 |
+
So basically we have talked about Model before.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:08,000 --> 00:00:11,000
|
| 15 |
+
So if you want to pass data between the pages,
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:11,000 --> 00:00:13,000
|
| 19 |
+
you can use a Model object.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:13,000 --> 00:00:15,000
|
| 23 |
+
So what we are doing till now is we got a Model object.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:15,000 --> 00:00:17,000
|
| 27 |
+
We are adding this data, which is "result",
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:17,000 --> 00:00:20,000
|
| 31 |
+
and then this data is going to the .jsp page,
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:20,000 --> 00:00:21,000
|
| 35 |
+
which you have mentioned here.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:21,000 --> 00:00:23,000
|
| 39 |
+
Okay, so before we talk about the ModelAndView,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:23,000 --> 00:00:25,000
|
| 43 |
+
because that View is important,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:25,000 --> 00:00:27,000
|
| 47 |
+
and the view is not working the way we want it.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:27,000 --> 00:00:31,000
|
| 51 |
+
So what I did is basically when I was moving the .jsp files,
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:31,000 --> 00:00:33,000
|
| 55 |
+
I've also moved the .css file.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:33,000 --> 00:00:35,000
|
| 59 |
+
Now, .css is a public file, right?
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:35,000 --> 00:00:38,000
|
| 63 |
+
Basically it is only for the styling purpose.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:38,000 --> 00:00:42,000
|
| 67 |
+
So you can put the .css file inside the webapp.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:42,000 --> 00:00:43,000
|
| 71 |
+
So, what?
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:43,000 --> 00:00:46,000
|
| 75 |
+
You have to move a .jsp but not the static files.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:46,000 --> 00:00:47,000
|
| 79 |
+
So you can put the static files here
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:47,000 --> 00:00:51,000
|
| 83 |
+
and then this should resolve the problem.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:51,000 --> 00:00:53,000
|
| 87 |
+
So let's go back to my browser
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:53,000 --> 00:00:55,000
|
| 91 |
+
and you can see it I've refreshed.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:55,000 --> 00:00:57,000
|
| 95 |
+
And if I type two numbers,
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:57,000 --> 00:00:59,000
|
| 99 |
+
now it is able to basically load this .css, right?
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:59,000 --> 00:01:01,000
|
| 103 |
+
So that was the issue last time.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:01,000 --> 00:01:06,000
|
| 107 |
+
Also, you can also put this .css file in this static folder.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:06,000 --> 00:01:09,000
|
| 111 |
+
Now, static is a folder which you can see in the resources.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:09,000 --> 00:01:10,000
|
| 115 |
+
So we have a static folder, which will be there.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:10,000 --> 00:01:13,000
|
| 119 |
+
And if you want to put any static resources like images,
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:13,000 --> 00:01:16,000
|
| 123 |
+
.css files, you can put that here.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:16,000 --> 00:01:17,000
|
| 127 |
+
Okay? So you have a choice.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:17,000 --> 00:01:21,000
|
| 131 |
+
You can either put that in the static file or in the webapp.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:21,000 --> 00:01:23,000
|
| 135 |
+
It makes sense to put that in static file
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:23,000 --> 00:01:26,000
|
| 139 |
+
is because all the styling and static content
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:26,000 --> 00:01:28,000
|
| 143 |
+
will be there in the static folder.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:28,000 --> 00:01:30,000
|
| 147 |
+
In the View, you will be having your .jsp.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:30,000 --> 00:01:33,000
|
| 151 |
+
It's more about structuring your project, right?
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:33,000 --> 00:01:36,000
|
| 155 |
+
So if I refresh or restart the application once again,
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:36,000 --> 00:01:37,000
|
| 159 |
+
let's see if that works.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:37,000 --> 00:01:39,000
|
| 163 |
+
Let's go back to the browser and refresh.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:39,000 --> 00:01:40,000
|
| 167 |
+
Okay, no problem.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:40,000 --> 00:01:42,000
|
| 171 |
+
You can see we are able to load the .css.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:42,000 --> 00:01:44,000
|
| 175 |
+
Okay, now let's talk about ModelAndView.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:44,000 --> 00:01:47,000
|
| 179 |
+
So when we talk about Model, it's only for data, right?
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:47,000 --> 00:01:50,000
|
| 183 |
+
So we are using Model here to add the data
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:50,000 --> 00:01:54,000
|
| 187 |
+
and also we are specifying a View name in the result.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:54,000 --> 00:01:57,000
|
| 191 |
+
What if you can put that review name in the object itself?
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:57,000 --> 00:02:00,000
|
| 195 |
+
What I'm saying is, instead of using Model,
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:02:00,000 --> 00:02:01,000
|
| 199 |
+
if you can use ModelAndView.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:03,000 --> 00:02:04,000
|
| 203 |
+
Which is this.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:04,000 --> 00:02:06,000
|
| 207 |
+
Instead of saying Model, I will say .mv.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:06,000 --> 00:02:08,000
|
| 211 |
+
.mv represents ModelAndView.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:08,000 --> 00:02:12,000
|
| 215 |
+
And with this ModelAndView object, I can add the attribute.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:12,000 --> 00:02:14,000
|
| 219 |
+
Okay, so we have a different name.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:15,000 --> 00:02:18,000
|
| 223 |
+
So I will say "addObject"
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:18,000 --> 00:02:21,000
|
| 227 |
+
and then we can say the object is "result".
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:21,000 --> 00:02:23,000
|
| 231 |
+
And then I can pass the data, which is "result",
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:23,000 --> 00:02:25,000
|
| 235 |
+
that's done.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:25,000 --> 00:02:28,000
|
| 239 |
+
Okay, but then what about the return here?
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:28,000 --> 00:02:31,000
|
| 243 |
+
So, of course we can still work with this, it will work.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:31,000 --> 00:02:35,000
|
| 247 |
+
But the best option is, instead of returning a name,
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:35,000 --> 00:02:36,000
|
| 251 |
+
return the .mv object
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:36,000 --> 00:02:39,000
|
| 255 |
+
because the ViewResolver will look at .mv object
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:39,000 --> 00:02:42,000
|
| 259 |
+
and it will have two things: the data, as well as the View.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:42,000 --> 00:02:44,000
|
| 263 |
+
It makes much more sense now, right?
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:44,000 --> 00:02:46,000
|
| 267 |
+
Because you are returning only one thing, not two.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:46,000 --> 00:02:48,000
|
| 271 |
+
Initially, you are returning the Model object
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:48,000 --> 00:02:50,000
|
| 275 |
+
and also the View name.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:50,000 --> 00:02:53,000
|
| 279 |
+
But now we are returning only one object.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:53,000 --> 00:02:54,000
|
| 283 |
+
Now, since we are changing it here .mv,
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:54,000 --> 00:02:57,000
|
| 287 |
+
we have to also make sure that you change it here
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:57,000 --> 00:03:02,000
|
| 291 |
+
by saying we are returning a ModelAndView object
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:03:02,000 --> 00:03:02,000
|
| 295 |
+
and that's done.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:03:02,000 --> 00:03:05,000
|
| 299 |
+
So okay, we got some angular bracket there.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:05,000 --> 00:03:06,000
|
| 303 |
+
And this should work.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:06,000 --> 00:03:07,000
|
| 307 |
+
Let's try.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:07,000 --> 00:03:10,000
|
| 311 |
+
Let's refresh this or restart the application.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:10,000 --> 00:03:12,000
|
| 315 |
+
Let's go back to our browser.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:12,000 --> 00:03:14,000
|
| 319 |
+
And if I refresh the page,
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:14,000 --> 00:03:16,000
|
| 323 |
+
you can see there's no problem on the homepage.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:16,000 --> 00:03:17,000
|
| 327 |
+
But if I add the values,
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:17,000 --> 00:03:20,000
|
| 331 |
+
and if I say submit, you can see we got an error,
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:20,000 --> 00:03:21,000
|
| 335 |
+
which is 404.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:21,000 --> 00:03:23,000
|
| 339 |
+
So basically, it is not able to find the "result" page.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:23,000 --> 00:03:24,000
|
| 343 |
+
You know why?
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:24,000 --> 00:03:25,000
|
| 347 |
+
Because nowhere,
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:25,000 --> 00:03:28,000
|
| 351 |
+
we are saying that we have to call a "result" page.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:28,000 --> 00:03:31,000
|
| 355 |
+
So that means when you add the data,
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:31,000 --> 00:03:33,000
|
| 359 |
+
you have to also set the ViewName.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:34,000 --> 00:03:36,000
|
| 363 |
+
So you have to mention the ViewName as "result".
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:36,000 --> 00:03:38,000
|
| 367 |
+
Now it should work.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:38,000 --> 00:03:41,000
|
| 371 |
+
Let's restart the application and go back to the browser.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:41,000 --> 00:03:43,000
|
| 375 |
+
Let's go to the homepage first
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:45,000 --> 00:03:47,000
|
| 379 |
+
and let's say 6 and 7.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:47,000 --> 00:03:48,000
|
| 383 |
+
Submit.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:48,000 --> 00:03:49,000
|
| 387 |
+
And you can see it works.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:49,000 --> 00:03:51,000
|
| 391 |
+
So basically you can use a Model object
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:51,000 --> 00:03:53,000
|
| 395 |
+
if you just want to work with Data,
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:03:53,000 --> 00:03:55,000
|
| 399 |
+
but if you want to return the ViewName as well,
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:03:55,000 --> 00:03:58,000
|
| 403 |
+
ModelAndView makes much more sense.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:03:58,000 --> 00:04:00,000
|
| 407 |
+
So yeah, that's it about ModelAndView
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:04:00,000 --> 00:04:03,000
|
| 411 |
+
where you can add the object and not just one object.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:03,000 --> 00:04:05,000
|
| 415 |
+
You can add multiple objects
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:05,000 --> 00:04:07,000
|
| 419 |
+
and you can set the ViewName as well.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:07,000 --> 00:04:09,000
|
| 423 |
+
And this is how basically you build an application.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:09,000 --> 00:04:12,000
|
| 427 |
+
You can do the same thing here.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:12,000 --> 00:04:13,000
|
| 431 |
+
Instead of saying String,
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:13,000 --> 00:04:15,000
|
| 435 |
+
we should also return ModelAndView here.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:15,000 --> 00:04:17,000
|
| 439 |
+
But again, that's something you can decide on,
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:17,000 --> 00:04:18,000
|
| 443 |
+
which one to use.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:18,000 --> 00:04:19,000
|
| 447 |
+
But you have both the options.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:19,000 --> 00:04:22,000
|
| 451 |
+
You can use String or you can use,
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:22,000 --> 00:04:24,000
|
| 455 |
+
you can return the ModelAndView object.
|
| 456 |
+
|
12 - Spring Boot Web/017 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.17%20ModelAndView
|
12 - Spring Boot Web/018 Need for ModelAttribute_en.srt
ADDED
|
@@ -0,0 +1,748 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(upbeat music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: So we are happy with whatever we have learned till now.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:09,000
|
| 11 |
+
Basically we have talked about model, object,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:09,000 --> 00:00:10,000
|
| 15 |
+
model and view.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:10,000 --> 00:00:13,000
|
| 19 |
+
There is one more called model attribute.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:13,000 --> 00:00:16,000
|
| 23 |
+
So let's understand why do we need a model attribute here.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:16,000 --> 00:00:20,000
|
| 27 |
+
So what I will do for that is I will go back to my index.jsp
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:20,000 --> 00:00:23,000
|
| 31 |
+
and what we are doing here is to add two numbers.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:23,000 --> 00:00:25,000
|
| 35 |
+
Now basically if I go to my output page,
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:25,000 --> 00:00:26,000
|
| 39 |
+
and if I go to the homepage,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:26,000 --> 00:00:29,000
|
| 43 |
+
basically you can see we are saying, "Hey, you know,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:29,000 --> 00:00:31,000
|
| 47 |
+
enter two numbers and we will add them".
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:31,000 --> 00:00:32,000
|
| 51 |
+
And that's what we are doing.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:32,000 --> 00:00:36,000
|
| 55 |
+
But let's say you are not just want to add two numbers.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:36,000 --> 00:00:39,000
|
| 59 |
+
Let's maybe you want to send some data to the server so
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:39,000 --> 00:00:41,000
|
| 63 |
+
that we can store that in database.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:41,000 --> 00:00:43,000
|
| 67 |
+
So now let's say you have an entity.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:43,000 --> 00:00:46,000
|
| 71 |
+
Now when you say entity, it means you are representing some
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:46,000 --> 00:00:50,000
|
| 75 |
+
real life entities like laptop or a house or a office
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:50,000 --> 00:00:53,000
|
| 79 |
+
or a factory or a mobile phone.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:53,000 --> 00:00:55,000
|
| 83 |
+
Now all this are entity, even humans.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:55,000 --> 00:00:57,000
|
| 87 |
+
When you say you are a student, you're a teacher,
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:57,000 --> 00:00:59,000
|
| 91 |
+
you're an engineer, you are a doctor,
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:59,000 --> 00:01:02,000
|
| 95 |
+
you are basically representing an entity
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:02,000 --> 00:01:04,000
|
| 99 |
+
and then you, maybe you want
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:04,000 --> 00:01:06,000
|
| 103 |
+
to show this entity in a database.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:06,000 --> 00:01:09,000
|
| 107 |
+
But again, we are not talking about database as of now,
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:09,000 --> 00:01:12,000
|
| 111 |
+
but let's say from this page, I want to send a data
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:12,000 --> 00:01:16,000
|
| 115 |
+
regarding an entity and then I want to directly accept
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:16,000 --> 00:01:19,000
|
| 119 |
+
that entity as an object on the server side.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:19,000 --> 00:01:21,000
|
| 123 |
+
Okay, I know a lot of things to imagine.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:21,000 --> 00:01:24,000
|
| 127 |
+
Let's go step by step, what I'm talking about is,
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:24,000 --> 00:01:26,000
|
| 131 |
+
let's say we have a alien class.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:26,000 --> 00:01:28,000
|
| 135 |
+
Now, when I say alien for this context,
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:28,000 --> 00:01:30,000
|
| 139 |
+
alien simply means programmers.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:30,000 --> 00:01:34,000
|
| 143 |
+
Okay, so I refer programmers as aliens and why?
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:34,000 --> 00:01:36,000
|
| 147 |
+
If you want to know, just go to YouTube
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:36,000 --> 00:01:39,000
|
| 151 |
+
and search for why I call Alien.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:39,000 --> 00:01:42,000
|
| 155 |
+
So you will get the idea, but anyway, that's not important.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:42,000 --> 00:01:45,000
|
| 159 |
+
Important is, let's say we have this form here.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:45,000 --> 00:01:49,000
|
| 163 |
+
Now instead of asking for a number, maybe I want to ask
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:49,000 --> 00:01:51,000
|
| 167 |
+
for a particular ID.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:51,000 --> 00:01:53,000
|
| 171 |
+
So every alien will have let's say two things, an ID
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:53,000 --> 00:01:57,000
|
| 175 |
+
which is a number which represents you and your name.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:57,000 --> 00:01:59,000
|
| 179 |
+
So I'm saying enter ID
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:59,000 --> 00:02:01,000
|
| 183 |
+
and this is for a ID, which is alien ID.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:02:01,000 --> 00:02:03,000
|
| 187 |
+
The ID is aid.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:02:03,000 --> 00:02:08,000
|
| 191 |
+
The name is aid, and I'm saying enter the name.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:02:08,000 --> 00:02:12,000
|
| 195 |
+
So I'm saying enter name and then this is for, aname.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:02:12,000 --> 00:02:16,000
|
| 199 |
+
Let's say that's the idea, I want to go for aname.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:16,000 --> 00:02:19,000
|
| 203 |
+
This is for aname, and then I'm saying submit.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:19,000 --> 00:02:22,000
|
| 207 |
+
Instead of saying add these two numbers, let's say I want
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:22,000 --> 00:02:24,000
|
| 211 |
+
to add a new entry for the alien.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:24,000 --> 00:02:26,000
|
| 215 |
+
Okay, so what is an alien?
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:26,000 --> 00:02:29,000
|
| 219 |
+
Alien is an entity which has two things, ID and a name.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:29,000 --> 00:02:32,000
|
| 223 |
+
And you are entering those details here.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:32,000 --> 00:02:35,000
|
| 227 |
+
And when you click on submit, you are requesting
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:35,000 --> 00:02:36,000
|
| 231 |
+
for add alien.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:36,000 --> 00:02:38,000
|
| 235 |
+
Okay, now how will this look?
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:38,000 --> 00:02:40,000
|
| 239 |
+
So if I go back, refresh this page
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:40,000 --> 00:02:42,000
|
| 243 |
+
or restart the application first,
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:42,000 --> 00:02:45,000
|
| 247 |
+
and if I go back to my output page, refresh this
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:45,000 --> 00:02:47,000
|
| 251 |
+
so you can see I'm asking for the ID.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:47,000 --> 00:02:50,000
|
| 255 |
+
Let's say ID is 101 and name here is Navin.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:50,000 --> 00:02:53,000
|
| 259 |
+
Now when I say submit, you can see it says 404.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:53,000 --> 00:02:56,000
|
| 263 |
+
You know why, it's because we don't have
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:56,000 --> 00:02:57,000
|
| 267 |
+
the controller for this.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:57,000 --> 00:02:59,000
|
| 271 |
+
So what I will do is I will,
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:59,000 --> 00:03:01,000
|
| 275 |
+
I need a controller for add alien.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:03:01,000 --> 00:03:04,000
|
| 279 |
+
So I will just reuse my code, I mean that's what you say.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:03:04,000 --> 00:03:08,000
|
| 283 |
+
Instead of copy pasting, I will say add alien.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:03:08,000 --> 00:03:11,000
|
| 287 |
+
And this time the method name is also add alien.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:03:11,000 --> 00:03:13,000
|
| 291 |
+
So basically I'm requesting for this particular
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:03:13,000 --> 00:03:15,000
|
| 295 |
+
UL here, this is my part.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:03:15,000 --> 00:03:17,000
|
| 299 |
+
But what about the parameters?
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:17,000 --> 00:03:20,000
|
| 303 |
+
Of course I'm not sending num one, I'm sending aid.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:20,000 --> 00:03:23,000
|
| 307 |
+
The variable is also an ID, I'm not sending num two.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:23,000 --> 00:03:28,000
|
| 311 |
+
What I'm sending is aname and aname is of type string
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:28,000 --> 00:03:31,000
|
| 315 |
+
and I'm saying aname here.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:31,000 --> 00:03:33,000
|
| 319 |
+
Now basically what we're doing is we are accepting
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:33,000 --> 00:03:34,000
|
| 323 |
+
that particular alien
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:34,000 --> 00:03:39,000
|
| 327 |
+
and the values are ID and aname.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:39,000 --> 00:03:40,000
|
| 331 |
+
That's what we are fetching from the URL
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:40,000 --> 00:03:43,000
|
| 335 |
+
because if you see the URL here,
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:43,000 --> 00:03:46,000
|
| 339 |
+
we are sending this data in the URL, so it should work.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:46,000 --> 00:03:48,000
|
| 343 |
+
So this data is coming here,
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:48,000 --> 00:03:49,000
|
| 347 |
+
but then what we are doing with data,
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:49,000 --> 00:03:52,000
|
| 351 |
+
of course we don't want to add basically let's say I want
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:52,000 --> 00:03:56,000
|
| 355 |
+
to create an aided object and save this data.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:56,000 --> 00:03:57,000
|
| 359 |
+
Of course, right, in the Java world,
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:57,000 --> 00:03:59,000
|
| 363 |
+
everything should be in the object
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:59,000 --> 00:04:01,000
|
| 367 |
+
and we don't have a object yet.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:04:01,000 --> 00:04:03,000
|
| 371 |
+
So even if I try to create the object of alien
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:04:03,000 --> 00:04:07,000
|
| 375 |
+
by saying object alien equal to new alien,
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:04:07,000 --> 00:04:10,000
|
| 379 |
+
unfortunately we don't have this object
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:04:10,000 --> 00:04:11,000
|
| 383 |
+
or this class itself.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:04:11,000 --> 00:04:15,000
|
| 387 |
+
So what we can do is we can create a class.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:04:15,000 --> 00:04:17,000
|
| 391 |
+
So you can get a class in the same package.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:04:17,000 --> 00:04:18,000
|
| 395 |
+
Normally it should be a different package,
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:04:18,000 --> 00:04:20,000
|
| 399 |
+
but we'll do that packaging part later.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:04:20,000 --> 00:04:22,000
|
| 403 |
+
Let's say everything is in the same package.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:04:22,000 --> 00:04:26,000
|
| 407 |
+
So if I go back here, SRC, main, Java,
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:04:26,000 --> 00:04:28,000
|
| 411 |
+
I have everything in this package, okay?
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:28,000 --> 00:04:31,000
|
| 415 |
+
If I go back to alien, alien needs two things.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:31,000 --> 00:04:34,000
|
| 419 |
+
One is private into ID
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:34,000 --> 00:04:38,000
|
| 423 |
+
and private string name,
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:38,000 --> 00:04:39,000
|
| 427 |
+
in fact not aname.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:39,000 --> 00:04:43,000
|
| 431 |
+
And I want this to be aid and aname.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:43,000 --> 00:04:46,000
|
| 435 |
+
And then for these two private variables,
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:46,000 --> 00:04:47,000
|
| 439 |
+
I need getters and setters.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:47,000 --> 00:04:50,000
|
| 443 |
+
So I will right click here, say generate getters
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:50,000 --> 00:04:53,000
|
| 447 |
+
for these two variables, click on, okay, we got that.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:53,000 --> 00:04:55,000
|
| 451 |
+
Also, I need a method for toString.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:55,000 --> 00:04:59,000
|
| 455 |
+
So I will say right click here, generate toString
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:59,000 --> 00:05:02,000
|
| 459 |
+
for which will return both these values.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:05:02,000 --> 00:05:04,000
|
| 463 |
+
So basically we've got a toString method,
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:05:04,000 --> 00:05:06,000
|
| 467 |
+
which will return this data here.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:05:06,000 --> 00:05:07,000
|
| 471 |
+
Okay, now what did it'll return?
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:05:07,000 --> 00:05:11,000
|
| 475 |
+
It'll print alien, the alien ID and the alien name.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:05:11,000 --> 00:05:14,000
|
| 479 |
+
That's what we want, nothing fancy,
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:05:14,000 --> 00:05:15,000
|
| 483 |
+
simple class, simple pojo.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:05:15,000 --> 00:05:17,000
|
| 487 |
+
Go back to the controller, now you can see we do have this
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:05:17,000 --> 00:05:19,000
|
| 491 |
+
class and we've got the object now.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:05:19,000 --> 00:05:23,000
|
| 495 |
+
I want to send the same object in this.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:05:23,000 --> 00:05:24,000
|
| 499 |
+
So I'm sending alien now
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:05:24,000 --> 00:05:28,000
|
| 503 |
+
and maybe in short result I want to send the alien itself.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:05:28,000 --> 00:05:30,000
|
| 507 |
+
So whatever data I'm receiving,
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:05:30,000 --> 00:05:32,000
|
| 511 |
+
I'm calling the same page, which is result.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:05:32,000 --> 00:05:36,000
|
| 515 |
+
But then the data which I'm sending now is alien data.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:05:36,000 --> 00:05:38,000
|
| 519 |
+
So of course in the result I have
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:05:38,000 --> 00:05:40,000
|
| 523 |
+
to make changes instead of printing result here
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:05:40,000 --> 00:05:42,000
|
| 527 |
+
I will print alien.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:05:42,000 --> 00:05:44,000
|
| 531 |
+
Or maybe we can have some fancy message here.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:05:44,000 --> 00:05:46,000
|
| 535 |
+
Let's do in the H2 tag, I want to say
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:05:46,000 --> 00:05:49,000
|
| 539 |
+
Welcome to Telusko, okay, so this is data.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:05:49,000 --> 00:05:51,000
|
| 543 |
+
I want to, this is what I want to print on the screen.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:05:51,000 --> 00:05:55,000
|
| 547 |
+
And then I want to print the alien object, not result.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:05:55,000 --> 00:05:58,000
|
| 551 |
+
Let's say just a simple alien object
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:05:58,000 --> 00:05:59,000
|
| 555 |
+
and maybe we can put that in a P tag.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:05:59,000 --> 00:06:02,000
|
| 559 |
+
I hope I have CSS for P.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:06:02,000 --> 00:06:04,000
|
| 563 |
+
Let's say I want to go for P tag here.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:06:04,000 --> 00:06:08,000
|
| 567 |
+
Just need to check if I have a P tag in the CSS.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:06:09,000 --> 00:06:12,000
|
| 571 |
+
Yeah, I do have, and now if I want to print this,
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:06:12,000 --> 00:06:14,000
|
| 575 |
+
basically this should work, right?
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:06:14,000 --> 00:06:16,000
|
| 579 |
+
So what I'm doing is from the index.jsp,
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:06:16,000 --> 00:06:17,000
|
| 583 |
+
this is my homepage.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:06:17,000 --> 00:06:19,000
|
| 587 |
+
I got two entries.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:06:19,000 --> 00:06:22,000
|
| 591 |
+
I'm calling the add alien, which will, the request goes
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:06:22,000 --> 00:06:23,000
|
| 595 |
+
to the controller, which is here.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:06:23,000 --> 00:06:25,000
|
| 599 |
+
And here we are saying add alien.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:06:25,000 --> 00:06:28,000
|
| 603 |
+
It'll accept these two values, aid and aname.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:06:28,000 --> 00:06:31,000
|
| 607 |
+
Save that in two variables, aid and aname.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:06:31,000 --> 00:06:33,000
|
| 611 |
+
And then we are creating an alien object.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:06:33,000 --> 00:06:36,000
|
| 615 |
+
But you know, we forgot one thing.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:06:36,000 --> 00:06:38,000
|
| 619 |
+
In the alien, we need to set the id,
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:06:38,000 --> 00:06:41,000
|
| 623 |
+
let's say aid is whatever you're sending from there.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:06:41,000 --> 00:06:43,000
|
| 627 |
+
And we have to also set the aname.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:06:43,000 --> 00:06:47,000
|
| 631 |
+
I will set the aname as aname, okay?
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:06:47,000 --> 00:06:49,000
|
| 635 |
+
So whatever data I've received here, I will just put
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:06:49,000 --> 00:06:52,000
|
| 639 |
+
that in the object and that object I'm sending here.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:06:52,000 --> 00:06:54,000
|
| 643 |
+
But the question is, will it work, let's try it out.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:06:54,000 --> 00:06:57,000
|
| 647 |
+
So I'll just run this and go back to the browser.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:06:57,000 --> 00:07:00,000
|
| 651 |
+
Let's say I want to go to the homepage, let's refresh.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:07:00,000 --> 00:07:02,000
|
| 655 |
+
Or maybe I can click on submit.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:07:02,000 --> 00:07:05,000
|
| 659 |
+
So when you click on submit, you can see we got data.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:07:05,000 --> 00:07:07,000
|
| 663 |
+
This is working, right, so it says, Welcome to Telusko,
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:07:07,000 --> 00:07:11,000
|
| 667 |
+
and then we are also printing the data.
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:07:11,000 --> 00:07:13,000
|
| 671 |
+
Okay, so this is working, but, but, but.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:07:13,000 --> 00:07:15,000
|
| 675 |
+
We have one little problem here.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:07:15,000 --> 00:07:17,000
|
| 679 |
+
The problem is actually not a problem,
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:07:17,000 --> 00:07:19,000
|
| 683 |
+
but then a better way to do it, don't you think?
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:07:19,000 --> 00:07:22,000
|
| 687 |
+
We are accepting value one by one anyway,
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:07:22,000 --> 00:07:23,000
|
| 691 |
+
we are sending this data
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:07:23,000 --> 00:07:25,000
|
| 695 |
+
and then we do have the alien object
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:07:25,000 --> 00:07:28,000
|
| 699 |
+
or alien class, which can represent these two values.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:07:28,000 --> 00:07:31,000
|
| 703 |
+
What if you have, your class has 10 values?
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:07:31,000 --> 00:07:33,000
|
| 707 |
+
What if your class has, okay, hyper example,
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:07:33,000 --> 00:07:35,000
|
| 711 |
+
let's say your class has 10 variables.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:07:35,000 --> 00:07:38,000
|
| 715 |
+
In that case, in this particular bracket, you have
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:07:38,000 --> 00:07:42,000
|
| 719 |
+
to write 10 times at the rate request per not cool, right?
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:07:42,000 --> 00:07:45,000
|
| 723 |
+
So can we just remove this
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:07:45,000 --> 00:07:49,000
|
| 727 |
+
and accept with one particular object?
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:07:49,000 --> 00:07:51,000
|
| 731 |
+
Okay, that will be good, right, so how do we do that?
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:07:51,000 --> 00:07:53,000
|
| 735 |
+
Let's see, the next video again, you know the title
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:07:53,000 --> 00:07:58,000
|
| 739 |
+
of the video it says Need for Model Attribute.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:07:58,000 --> 00:07:59,000
|
| 743 |
+
So yeah, we are going to use model attribute
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:07:59,000 --> 00:08:00,000
|
| 747 |
+
to solve this problem.
|
| 748 |
+
|
12 - Spring Boot Web/018 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.18%20Need%20for%20ModelAttribute
|
12 - Spring Boot Web/019 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(soft music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: So let's use the model attribute to solve this problem.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:10,000
|
| 11 |
+
So instead of using request param for these two variables,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:10,000 --> 00:00:12,000
|
| 15 |
+
I can just remove them.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:12,000 --> 00:00:15,000
|
| 19 |
+
And what if I can simply use alien, alien?
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:15,000 --> 00:00:16,000
|
| 23 |
+
Our job is done.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:16,000 --> 00:00:18,000
|
| 27 |
+
So what I'm expecting is from the form,
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:18,000 --> 00:00:20,000
|
| 31 |
+
when then this data is coming,
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:20,000 --> 00:00:22,000
|
| 35 |
+
it'll directly assign the value to the alien object.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:22,000 --> 00:00:26,000
|
| 39 |
+
So basically I want Spring to create this object.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:26,000 --> 00:00:27,000
|
| 43 |
+
Basically I don't want to do this step,
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:27,000 --> 00:00:29,000
|
| 47 |
+
I want to skip this steps.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:29,000 --> 00:00:31,000
|
| 51 |
+
So I want Spring to create this object
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:31,000 --> 00:00:34,000
|
| 55 |
+
and then assign those two values
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:34,000 --> 00:00:37,000
|
| 59 |
+
which is coming from the browser.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:37,000 --> 00:00:40,000
|
| 63 |
+
So that is, not the browser but the request.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:40,000 --> 00:00:41,000
|
| 67 |
+
So can we do that?
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:41,000 --> 00:00:44,000
|
| 71 |
+
So to achieve that we have to use something called
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:44,000 --> 00:00:46,000
|
| 75 |
+
a model attribute.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:46,000 --> 00:00:48,000
|
| 79 |
+
Now this is the annotation which is responsible
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:48,000 --> 00:00:51,000
|
| 83 |
+
to assign the value to the alien object.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:51,000 --> 00:00:52,000
|
| 87 |
+
Of course you can assign a different name to it.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:52,000 --> 00:00:55,000
|
| 91 |
+
So even this becomes optional.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:55,000 --> 00:00:56,000
|
| 95 |
+
Model view,
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:56,000 --> 00:00:59,000
|
| 99 |
+
you can simply return the result here, lemme show you that.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:59,000 --> 00:01:03,000
|
| 103 |
+
So I can just remove this and instead of model and view
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:03,000 --> 00:01:04,000
|
| 107 |
+
let's return a string again.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:04,000 --> 00:01:06,000
|
| 111 |
+
So you don't have to return the object.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:06,000 --> 00:01:10,000
|
| 115 |
+
So here we can mention I'm calling the result page.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:10,000 --> 00:01:11,000
|
| 119 |
+
So this object I'm receiving here
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:11,000 --> 00:01:14,000
|
| 123 |
+
and that object will go to the JSB page.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:14,000 --> 00:01:16,000
|
| 127 |
+
Okay, that's what I'm expecting now.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:16,000 --> 00:01:18,000
|
| 131 |
+
So this step is also optional
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:18,000 --> 00:01:20,000
|
| 135 |
+
and that can be done with the helper model object,
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:20,000 --> 00:01:21,000
|
| 139 |
+
which we have talked about.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:21,000 --> 00:01:23,000
|
| 143 |
+
And now let's refresh this.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:23,000 --> 00:01:24,000
|
| 147 |
+
Let's see if it works.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:24,000 --> 00:01:27,000
|
| 151 |
+
Okay, no problem on the server, we are running it.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:27,000 --> 00:01:29,000
|
| 155 |
+
Let's go back to the homepage
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:29,000 --> 00:01:31,000
|
| 159 |
+
and this time we'll enter some different data.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:31,000 --> 00:01:33,000
|
| 163 |
+
101, Harsh, click on submit and it worked.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:33,000 --> 00:01:37,000
|
| 167 |
+
You can see that we got 101 and we also got Harsh there.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:37,000 --> 00:01:38,000
|
| 171 |
+
So this is working.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:38,000 --> 00:01:40,000
|
| 175 |
+
So basically we can use a model attribute.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:40,000 --> 00:01:42,000
|
| 179 |
+
So let's say I want to change something.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:42,000 --> 00:01:45,000
|
| 183 |
+
So instead of alien, which I'm printing here,
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:45,000 --> 00:01:46,000
|
| 187 |
+
what if I want to print alien1?
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:47,000 --> 00:01:48,000
|
| 191 |
+
Now basically when I'm printing alien1,
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:48,000 --> 00:01:51,000
|
| 195 |
+
let's see what happens if I restart my server
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:51,000 --> 00:01:52,000
|
| 199 |
+
and let's go back to the homepage.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:52,000 --> 00:01:55,000
|
| 203 |
+
If I click on submit here with different data,
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:55,000 --> 00:01:57,000
|
| 207 |
+
you can see it's not working.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:57,000 --> 00:02:01,000
|
| 211 |
+
Reason you are sending this data with a name alien
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:01,000 --> 00:02:04,000
|
| 215 |
+
but what you are receiving here is alien1.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:04,000 --> 00:02:06,000
|
| 219 |
+
So what if you want to have alien1 here?
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:06,000 --> 00:02:10,000
|
| 223 |
+
So what you can do is you can give that name here.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:10,000 --> 00:02:11,000
|
| 227 |
+
So you can say alien1.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:11,000 --> 00:02:14,000
|
| 231 |
+
So now this name will be representing there.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:14,000 --> 00:02:18,000
|
| 235 |
+
So let's try and go back, say submit.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:18,000 --> 00:02:19,000
|
| 239 |
+
So you can see it works.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:19,000 --> 00:02:21,000
|
| 243 |
+
So basically if you want to have a different name
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:21,000 --> 00:02:24,000
|
| 247 |
+
than alien, then you have to mention that thing here.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:24,000 --> 00:02:25,000
|
| 251 |
+
But what if it's the same name?
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:25,000 --> 00:02:29,000
|
| 255 |
+
What if it is alien and go back here
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:29,000 --> 00:02:31,000
|
| 259 |
+
and let's remove this.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:31,000 --> 00:02:32,000
|
| 263 |
+
So this will work, right?
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:32,000 --> 00:02:36,000
|
| 267 |
+
But what if I also remove the model attribute?
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:36,000 --> 00:02:37,000
|
| 271 |
+
Is it really compulsory?
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:37,000 --> 00:02:38,000
|
| 275 |
+
Let's try.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:38,000 --> 00:02:40,000
|
| 279 |
+
So I'm removing model attribute now,
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:40,000 --> 00:02:41,000
|
| 283 |
+
so there's no model attribute.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:41,000 --> 00:02:46,000
|
| 287 |
+
Let's go back and submit, it still works.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:46,000 --> 00:02:48,000
|
| 291 |
+
So basically the model attribute is optional.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:48,000 --> 00:02:50,000
|
| 295 |
+
It is something which comes behind the scene.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:50,000 --> 00:02:53,000
|
| 299 |
+
It is responsible to add your data to the alien.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:53,000 --> 00:02:55,000
|
| 303 |
+
So when you don't want to have a different name,
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:02:55,000 --> 00:02:57,000
|
| 307 |
+
you can completely skip model attribute.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:02:57,000 --> 00:02:59,000
|
| 311 |
+
And that's why most of the time you will not see
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:02:59,000 --> 00:03:01,000
|
| 315 |
+
model attribute annotation there
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:01,000 --> 00:03:03,000
|
| 319 |
+
because most of the time we are using the same name.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:03,000 --> 00:03:06,000
|
| 323 |
+
But yes, if you want to have a different name here,
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:06,000 --> 00:03:09,000
|
| 327 |
+
then we have to use the model attribute annotation.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:09,000 --> 00:03:11,000
|
| 331 |
+
Not just that, we can also use model attribute
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:11,000 --> 00:03:12,000
|
| 335 |
+
on method level.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:12,000 --> 00:03:16,000
|
| 339 |
+
Basically we have used that for the method arguments.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:16,000 --> 00:03:18,000
|
| 343 |
+
But what if you want to use on a method level,
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:18,000 --> 00:03:20,000
|
| 347 |
+
something like this.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:20,000 --> 00:03:22,000
|
| 351 |
+
Let's say I have this page here.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:22,000 --> 00:03:23,000
|
| 355 |
+
Now I'm saying welcome to Telusko,
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:23,000 --> 00:03:25,000
|
| 359 |
+
I'm also printing the alien name
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:25,000 --> 00:03:29,000
|
| 363 |
+
and maybe I also want to print that welcome to the course.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:29,000 --> 00:03:31,000
|
| 367 |
+
So I will use a P tag here
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:31,000 --> 00:03:32,000
|
| 371 |
+
and close the P tag.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:32,000 --> 00:03:36,000
|
| 375 |
+
And inside this I want to say
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:36,000 --> 00:03:41,000
|
| 379 |
+
welcome to the Java world.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:41,000 --> 00:03:42,000
|
| 383 |
+
Okay?
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:42,000 --> 00:03:44,000
|
| 387 |
+
Now of course this is a Java course
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:44,000 --> 00:03:45,000
|
| 391 |
+
so it makes sense to print this.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:45,000 --> 00:03:48,000
|
| 395 |
+
But what if I want to print different things
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:03:48,000 --> 00:03:49,000
|
| 399 |
+
for different courses?
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:03:49,000 --> 00:03:51,000
|
| 403 |
+
Let's say for blockchain it should be
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:03:51,000 --> 00:03:52,000
|
| 407 |
+
welcome to the blockchain world,
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:03:52,000 --> 00:03:54,000
|
| 411 |
+
welcome to the AI world,
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:03:54,000 --> 00:03:57,000
|
| 415 |
+
welcome to the .NET world, something like this.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:03:57,000 --> 00:03:58,000
|
| 419 |
+
So I want this to be dynamic,
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:03:58,000 --> 00:04:01,000
|
| 423 |
+
not something like Java everywhere.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:01,000 --> 00:04:03,000
|
| 427 |
+
So we can put that in as a variable.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:03,000 --> 00:04:05,000
|
| 431 |
+
So you can say variable name is course
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:05,000 --> 00:04:09,000
|
| 435 |
+
and I can just use a dollar symbol here, right?
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:09,000 --> 00:04:10,000
|
| 439 |
+
So we have to provide this value
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:10,000 --> 00:04:12,000
|
| 443 |
+
because if you don't provide this value,
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:12,000 --> 00:04:14,000
|
| 447 |
+
you can see in the home controller nowhere we are specifying
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:14,000 --> 00:04:16,000
|
| 451 |
+
the value for the course.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:16,000 --> 00:04:19,000
|
| 455 |
+
And if we don't specify the value for it,
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:19,000 --> 00:04:22,000
|
| 459 |
+
let's read on this application without specifying
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:22,000 --> 00:04:23,000
|
| 463 |
+
any value for course.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:23,000 --> 00:04:25,000
|
| 467 |
+
And let's refresh the result page.
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:25,000 --> 00:04:28,000
|
| 471 |
+
You can see it says welcome to the world, which world?
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:28,000 --> 00:04:30,000
|
| 475 |
+
Basically it's not printing the course.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:30,000 --> 00:04:31,000
|
| 479 |
+
So how do I assign the value?
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:31,000 --> 00:04:33,000
|
| 483 |
+
Of course you can assign the value from here,
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:04:33,000 --> 00:04:35,000
|
| 487 |
+
you can create a model view object
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:04:35,000 --> 00:04:38,000
|
| 491 |
+
or maybe you can create a model object, add the data there,
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:04:38,000 --> 00:04:42,000
|
| 495 |
+
or we can create a separate method which will return
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:04:42,000 --> 00:04:43,000
|
| 499 |
+
the course names.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:04:43,000 --> 00:04:46,000
|
| 503 |
+
I will say public string course name.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:04:46,000 --> 00:04:48,000
|
| 507 |
+
And of course this can be dynamic.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:04:48,000 --> 00:04:49,000
|
| 511 |
+
Now you can write some JDBC code,
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:04:49,000 --> 00:04:52,000
|
| 515 |
+
you can write some database code to create your database
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:04:52,000 --> 00:04:54,000
|
| 519 |
+
and check which course this person is enrolled into.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:04:54,000 --> 00:04:58,000
|
| 523 |
+
But at this point I'll just make it static.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:04:58,000 --> 00:05:00,000
|
| 527 |
+
At least we have a control now, right?
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:05:00,000 --> 00:05:01,000
|
| 531 |
+
I want to return Java here
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:05:02,000 --> 00:05:04,000
|
| 535 |
+
and you can return whatever you want.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:05:04,000 --> 00:05:06,000
|
| 539 |
+
You can write the complete code as I mentioned before.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:05:06,000 --> 00:05:09,000
|
| 543 |
+
But here just to keep it simple, I'm saying Java.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:05:09,000 --> 00:05:12,000
|
| 547 |
+
And here I can use a model attribute
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:05:12,000 --> 00:05:15,000
|
| 551 |
+
and in the bracket I can mention the course.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:05:15,000 --> 00:05:18,000
|
| 555 |
+
So basically what we are doing is the value for the course
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:05:18,000 --> 00:05:20,000
|
| 559 |
+
is whatever this particular method returns.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:05:20,000 --> 00:05:22,000
|
| 563 |
+
It is Java, so it'll say Java.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:05:22,000 --> 00:05:25,000
|
| 567 |
+
If we return something else, it'll be that particular value.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:05:25,000 --> 00:05:28,000
|
| 571 |
+
So we can use model attribute on top of the method as well.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:05:28,000 --> 00:05:30,000
|
| 575 |
+
And that's why we use it most of the time.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:05:30,000 --> 00:05:34,000
|
| 579 |
+
If you want to have some values in the result page,
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:05:34,000 --> 00:05:37,000
|
| 583 |
+
which is not generated by a method or some other methods
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:05:39,000 --> 00:05:42,000
|
| 587 |
+
or which is common for most of the requests.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:05:42,000 --> 00:05:44,000
|
| 591 |
+
So you can see I'm restarting the application,
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:05:44,000 --> 00:05:48,000
|
| 595 |
+
let's refresh this and it worked.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:05:48,000 --> 00:05:51,000
|
| 599 |
+
Now this basically that's how you use the model attribute
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:05:51,000 --> 00:05:53,000
|
| 603 |
+
on top of this.
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:05:53,000 --> 00:05:54,000
|
| 607 |
+
So yeah, that's it about model attribute.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:05:54,000 --> 00:05:57,000
|
| 611 |
+
I hope it makes sense, some sense now.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:05:57,000 --> 00:05:59,000
|
| 615 |
+
When to use, when not to use the model attribute.
|
| 616 |
+
|
12 - Spring Boot Web/external-links.txt
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
002 Source-Code
|
| 3 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.2%20Creating%20A%20Servlet%20Project%201
|
| 4 |
+
|
| 5 |
+
003 Source-Code
|
| 6 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.3%20Running%20Tomcat
|
| 7 |
+
|
| 8 |
+
004 Source-Code
|
| 9 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.4%20Servlet%20Mapping
|
| 10 |
+
|
| 11 |
+
005 Source-Code
|
| 12 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.5%20Responding%20To%20The%20Client
|
| 13 |
+
|
| 14 |
+
007 Source-Code
|
| 15 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.7%20Creating%20a%20Spring%20Boot%20Web%20App%20Project
|
| 16 |
+
|
| 17 |
+
008 Source-Code
|
| 18 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.8%20Creating%20a%20JSP%20Page
|
| 19 |
+
|
| 20 |
+
009 Source-Code
|
| 21 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.9%20Creating%20a%20Controller
|
| 22 |
+
|
| 23 |
+
010 Source-Code
|
| 24 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.10%20RequestMapping
|
| 25 |
+
|
| 26 |
+
011 Source-Code
|
| 27 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.11%20Sending%20data%20to%20Controller
|
| 28 |
+
|
| 29 |
+
012 Source-Code
|
| 30 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.12%20Accepting%20Data%20the%20servlet%20way
|
| 31 |
+
|
| 32 |
+
013 Source-Code
|
| 33 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.13%20Display%20Data%20on%20Result%20Page
|
| 34 |
+
|
| 35 |
+
014 Source-Code
|
| 36 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.14%20RequestParam
|
| 37 |
+
|
| 38 |
+
015 Source-Code
|
| 39 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.15%20Model%20Object
|
| 40 |
+
|
| 41 |
+
016 Source-Code
|
| 42 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.16%20Setting%20Prefix%20and%20Suffix
|
| 43 |
+
|
| 44 |
+
017 Source-Code
|
| 45 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.17%20ModelAndView
|
| 46 |
+
|
| 47 |
+
018 Source-Code
|
| 48 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/6%20Spring%20%20Boot%20Web/5.18%20Need%20for%20ModelAttribute
|
| 49 |
+
|
| 50 |
+
019 Source-Code
|
| 51 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b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:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: In this module, we'll talk about Spring MVC.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:07,000
|
| 11 |
+
Now you will say, "Hey, we have done that before," right?
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:10,000
|
| 15 |
+
We have talked about Spring MVC.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:10,000 --> 00:00:12,000
|
| 19 |
+
Actually we talked about Spring Boot MVC.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:12,000 --> 00:00:14,000
|
| 23 |
+
So basically, we have used MVC,
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:14,000 --> 00:00:16,000
|
| 27 |
+
but then with the help of Spring Boot.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:16,000 --> 00:00:19,000
|
| 31 |
+
Now, what it does is it makes our job easy
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:19,000 --> 00:00:20,000
|
| 35 |
+
and that's what we have done, right?
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:20,000 --> 00:00:23,000
|
| 39 |
+
So basically, we were able to build the controller.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:23,000 --> 00:00:24,000
|
| 43 |
+
We were able to go to our page.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:24,000 --> 00:00:25,000
|
| 47 |
+
So, what page I'm talking about?
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:25,000 --> 00:00:28,000
|
| 51 |
+
So if I run this application once again,
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:28,000 --> 00:00:31,000
|
| 55 |
+
just show you what we have done till now.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:31,000 --> 00:00:33,000
|
| 59 |
+
If I go to the homepage,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:33,000 --> 00:00:34,000
|
| 63 |
+
you can say it is giving you this page
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:34,000 --> 00:00:38,000
|
| 67 |
+
because we have done with the UI, with the controllers,
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:38,000 --> 00:00:41,000
|
| 71 |
+
I mean controllers, property files,
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:41,000 --> 00:00:43,000
|
| 75 |
+
we have done some configuration here, right?
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:43,000 --> 00:00:44,000
|
| 79 |
+
Now, this works,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:44,000 --> 00:00:47,000
|
| 83 |
+
but then we have talked about Spring Boot, right?
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:47,000 --> 00:00:49,000
|
| 87 |
+
It makes your work easy.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:49,000 --> 00:00:51,000
|
| 91 |
+
There's another way of doing the same thing
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:51,000 --> 00:00:52,000
|
| 95 |
+
without Spring Boot.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:52,000 --> 00:00:56,000
|
| 99 |
+
That is, with the help of Spring Framework directly.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:56,000 --> 00:00:58,000
|
| 103 |
+
So, we have a component called Spring MVC
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:58,000 --> 00:01:00,000
|
| 107 |
+
which we're going to focus in this section.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:00,000 --> 00:01:02,000
|
| 111 |
+
Now here, we'll do the same thing, okay?
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:02,000 --> 00:01:04,000
|
| 115 |
+
Same project, maybe we'll reuse the code,
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:04,000 --> 00:01:06,000
|
| 119 |
+
but we'll not be using Spring Boot.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:06,000 --> 00:01:11,000
|
| 123 |
+
That means we have to do lot of configuration by ourself
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:11,000 --> 00:01:14,000
|
| 127 |
+
and in the entire section, of course, nothing will be new
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:14,000 --> 00:01:17,000
|
| 131 |
+
because the flow will be same, the controller will be same.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:17,000 --> 00:01:19,000
|
| 135 |
+
What will change is the configuration.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:19,000 --> 00:01:21,000
|
| 139 |
+
So I want your focus mostly on the configuration,
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:21,000 --> 00:01:23,000
|
| 143 |
+
not on the other things.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:23,000 --> 00:01:24,000
|
| 147 |
+
So, what are the things we need?
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:24,000 --> 00:01:26,000
|
| 151 |
+
Now, first of all, if you want to build web application
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:26,000 --> 00:01:27,000
|
| 155 |
+
without Spring Boot,
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:27,000 --> 00:01:30,000
|
| 159 |
+
basically in this project we have used a embedded Tomcat.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:30,000 --> 00:01:31,000
|
| 163 |
+
But then in Spring Framework,
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:31,000 --> 00:01:34,000
|
| 167 |
+
we'll be using a external Tomcat.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:34,000 --> 00:01:35,000
|
| 171 |
+
So what you need,
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:35,000 --> 00:01:37,000
|
| 175 |
+
the first thing is the external Tomcat.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:37,000 --> 00:01:39,000
|
| 179 |
+
How will you get that? It's very easy.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:39,000 --> 00:01:42,000
|
| 183 |
+
You can just go to the Google
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:42,000 --> 00:01:45,000
|
| 187 |
+
and search for Apache Tomcat download,
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:45,000 --> 00:01:47,000
|
| 191 |
+
and you can get the version 10, which works.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:47,000 --> 00:01:50,000
|
| 195 |
+
In fact, I'll be using version 10 here.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:50,000 --> 00:01:51,000
|
| 199 |
+
And depend upon which OS you are using,
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:51,000 --> 00:01:55,000
|
| 203 |
+
you can get this and it'd work.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:55,000 --> 00:01:58,000
|
| 207 |
+
So basically, I've got the zip folder,
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:58,000 --> 00:01:59,000
|
| 211 |
+
then I unzipped it,
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:59,000 --> 00:02:01,000
|
| 215 |
+
and now I have that in my Download folder.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:01,000 --> 00:02:02,000
|
| 219 |
+
That's the first thing you need.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:02,000 --> 00:02:04,000
|
| 223 |
+
The next thing you will need is a IDE.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:04,000 --> 00:02:07,000
|
| 227 |
+
Okay, we are using the IntelliJ, right?
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:07,000 --> 00:02:09,000
|
| 231 |
+
But then, IntelliJ IDEA which we are using
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:09,000 --> 00:02:09,000
|
| 235 |
+
is a community version,
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:09,000 --> 00:02:12,000
|
| 239 |
+
which means basically we have to use...
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:12,000 --> 00:02:15,000
|
| 243 |
+
It doesn't, by default, support the external servers.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:15,000 --> 00:02:16,000
|
| 247 |
+
If you want to use IntelliJ,
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:16,000 --> 00:02:19,000
|
| 251 |
+
you can use the Ultimate version.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:19,000 --> 00:02:21,000
|
| 255 |
+
Now, since we want to focus on the free softwares here,
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:21,000 --> 00:02:23,000
|
| 259 |
+
so I'm going to use Eclipse for this section
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:23,000 --> 00:02:26,000
|
| 263 |
+
because Eclipse is free and we can run the servers.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:26,000 --> 00:02:27,000
|
| 267 |
+
Okay, before we go ahead,
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:27,000 --> 00:02:30,000
|
| 271 |
+
I want to show you one more thing regarding the Tomcat.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:30,000 --> 00:02:32,000
|
| 275 |
+
So, you can see it says Tomcat 10.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:32,000 --> 00:02:35,000
|
| 279 |
+
They have made some changes from Java EE to Jakarta EE.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:35,000 --> 00:02:38,000
|
| 283 |
+
So basically, certain things will change in Tomcat 10.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:38,000 --> 00:02:41,000
|
| 287 |
+
So instead of using Java X, we are going to use Jakarta X,
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:41,000 --> 00:02:43,000
|
| 291 |
+
I mean Jakarta, not X.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:43,000 --> 00:02:45,000
|
| 295 |
+
So if you don't want to use Jakarta,
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:45,000 --> 00:02:48,000
|
| 299 |
+
you can still go back to Tomcat 9 which uses Java X,
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:48,000 --> 00:02:51,000
|
| 303 |
+
and you can still use it.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:02:51,000 --> 00:02:52,000
|
| 307 |
+
Okay, anyway, once we got this software,
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:02:52,000 --> 00:02:54,000
|
| 311 |
+
it doesn't matter which one you get,
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:02:54,000 --> 00:02:57,000
|
| 315 |
+
we can start working on the same project.
|
| 316 |
+
|
13 - Exploring Web MVC without Spring Boot/002 Creating a Spring MVC Project_en.srt
ADDED
|
@@ -0,0 +1,776 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:05,000
|
| 7 |
+
-: So the first step here is to get IDE.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:05,000 --> 00:00:07,000
|
| 11 |
+
We have talked about we can use Eclipse here,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:08,000
|
| 15 |
+
and it's very easy.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:08,000 --> 00:00:10,000
|
| 19 |
+
You can just go to Google, download the Eclipse version,
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:10,000 --> 00:00:14,000
|
| 23 |
+
but make sure you get the Eclipse Java EE version,
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:14,000 --> 00:00:17,000
|
| 27 |
+
not normal Eclipse for Java developers.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:17,000 --> 00:00:17,000
|
| 31 |
+
So you have to make sure
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:17,000 --> 00:00:19,000
|
| 35 |
+
that you get it for enterprise developers.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:19,000 --> 00:00:21,000
|
| 39 |
+
And once you have that, you can open Eclipse
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:21,000 --> 00:00:23,000
|
| 43 |
+
and I'm opening Eclipse now.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:23,000 --> 00:00:25,000
|
| 47 |
+
Okay, so this is my Eclipse here
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:25,000 --> 00:00:29,000
|
| 51 |
+
and then I'm using a workspace name as spring.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:29,000 --> 00:00:31,000
|
| 55 |
+
Of course, when you open Eclipse, it will ask you
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:31,000 --> 00:00:33,000
|
| 59 |
+
for a name, for the workspace,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:33,000 --> 00:00:34,000
|
| 63 |
+
just mention whatever you want.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:34,000 --> 00:00:36,000
|
| 67 |
+
I have a workspace here with name spring.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:36,000 --> 00:00:38,000
|
| 71 |
+
Okay, so in this, let's create a project.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:38,000 --> 00:00:40,000
|
| 75 |
+
Now since we are not using Spring Boot,
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:40,000 --> 00:00:43,000
|
| 79 |
+
so we'll not be going to the official Spring initializer,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:43,000 --> 00:00:45,000
|
| 83 |
+
we will be using the Maven project.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:45,000 --> 00:00:48,000
|
| 87 |
+
So here let me create a Maven project.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:48,000 --> 00:00:52,000
|
| 91 |
+
So I will just go to the File, and say New, Maven Project.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:52,000 --> 00:00:53,000
|
| 95 |
+
Now since this will be a web application,
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:53,000 --> 00:00:54,000
|
| 99 |
+
we'll choose a different doc type.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:54,000 --> 00:00:56,000
|
| 103 |
+
So just observe what I'm doing.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:56,000 --> 00:00:57,000
|
| 107 |
+
So I will click on Next here,
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:00:57,000 --> 00:00:59,000
|
| 111 |
+
and this is where it says catalog.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:00:59,000 --> 00:01:01,000
|
| 115 |
+
I will be clicking on Internal.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:01,000 --> 00:01:04,000
|
| 119 |
+
In the Internal catalog, instead of going for quickstart,
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:04,000 --> 00:01:06,000
|
| 123 |
+
we'll be going for a web application,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:06,000 --> 00:01:09,000
|
| 127 |
+
because we are building a Spring web application
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:09,000 --> 00:01:10,000
|
| 131 |
+
using Spring MVC.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:10,000 --> 00:01:12,000
|
| 135 |
+
So select this, click on Next.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:12,000 --> 00:01:13,000
|
| 139 |
+
It will ask you for the group ID.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:13,000 --> 00:01:15,000
|
| 143 |
+
I will say group ID is com.telusko,
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:15,000 --> 00:01:18,000
|
| 147 |
+
and the artifact ID, you can name anything you want,
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:18,000 --> 00:01:21,000
|
| 151 |
+
but I will say SpringMVCDemo,
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:21,000 --> 00:01:23,000
|
| 155 |
+
and nothing much, click on Finish.
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:23,000 --> 00:01:25,000
|
| 159 |
+
This will give you a beautiful Maven project.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:25,000 --> 00:01:27,000
|
| 163 |
+
So by the time it is happening, what I will do is
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:27,000 --> 00:01:29,000
|
| 167 |
+
I will go back to my download
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:29,000 --> 00:01:32,000
|
| 171 |
+
and show you how your Tomcat folder looks like.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:32,000 --> 00:01:34,000
|
| 175 |
+
So this is the Tomcat which I'm using,
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:34,000 --> 00:01:38,000
|
| 179 |
+
which is Apache Tomcat 10.1.16.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:38,000 --> 00:01:40,000
|
| 183 |
+
And in this you can see there are different folders.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:40,000 --> 00:01:43,000
|
| 187 |
+
One of the important folder is bin, because in this folder,
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:43,000 --> 00:01:46,000
|
| 191 |
+
you will find the start and stop .sh.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:46,000 --> 00:01:48,000
|
| 195 |
+
This is how you basically run your Tomcat.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:48,000 --> 00:01:49,000
|
| 199 |
+
But do we really have to use this?
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:49,000 --> 00:01:51,000
|
| 203 |
+
We'll see that in some time.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:51,000 --> 00:01:53,000
|
| 207 |
+
So looks like Maven is taking some time.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:53,000 --> 00:01:55,000
|
| 211 |
+
So my Eclipse just crashed. Let me just do that once again.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:57,000 --> 00:01:59,000
|
| 215 |
+
Click on Finish. It is creating the project.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:01:59,000 --> 00:02:01,000
|
| 219 |
+
So when it's creating the project, you can see it is asking
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:01,000 --> 00:02:04,000
|
| 223 |
+
for the group ID, artifact ID, version, and package.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:04,000 --> 00:02:07,000
|
| 227 |
+
I will say yes, this is what I want to go for, and done.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:07,000 --> 00:02:09,000
|
| 231 |
+
You can see we have project is done,
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:09,000 --> 00:02:11,000
|
| 235 |
+
which we can see our project section here
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:11,000 --> 00:02:12,000
|
| 239 |
+
on the left hand side.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:12,000 --> 00:02:14,000
|
| 243 |
+
And this is your console, this is your outline.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:14,000 --> 00:02:16,000
|
| 247 |
+
We'll see later. Not needed now.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:16,000 --> 00:02:18,000
|
| 251 |
+
Okay, so this is the project which we got.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:18,000 --> 00:02:20,000
|
| 255 |
+
Now in this, if you open your pom.xml,
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:20,000 --> 00:02:23,000
|
| 259 |
+
no where we are saying this is a Spring project.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:23,000 --> 00:02:25,000
|
| 263 |
+
So if you want this to work, we have to make sure
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:25,000 --> 00:02:28,000
|
| 267 |
+
that you get your Spring dependencies here, okay?
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:28,000 --> 00:02:30,000
|
| 271 |
+
Now why? I will show you in some time.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:30,000 --> 00:02:31,000
|
| 275 |
+
Let's see the folder structure.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:31,000 --> 00:02:35,000
|
| 279 |
+
So if you see, if you expand src, you have a main folder.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:35,000 --> 00:02:38,000
|
| 283 |
+
You don't have a Java folder here, that's weird.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:38,000 --> 00:02:40,000
|
| 287 |
+
And in this you have a webapp.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:40,000 --> 00:02:43,000
|
| 291 |
+
Inside this, you have index.jsp, which is this page.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:43,000 --> 00:02:45,000
|
| 295 |
+
And the good thing is we'll not be needing this JSP,
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:45,000 --> 00:02:47,000
|
| 299 |
+
because we already have our two pages.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:47,000 --> 00:02:50,000
|
| 303 |
+
So I will delete this particular page here.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:02:50,000 --> 00:02:52,000
|
| 307 |
+
And if you go to the Java Resources,
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:02:52,000 --> 00:02:55,000
|
| 311 |
+
you can see we don't have a java folder yet.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:02:55,000 --> 00:02:57,000
|
| 315 |
+
So what I will do is I will just go back to main,
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:02:57,000 --> 00:02:59,000
|
| 319 |
+
and make sure that I create a java folder,
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:02:59,000 --> 00:03:02,000
|
| 323 |
+
it's because I'll be putting my code there.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:02,000 --> 00:03:04,000
|
| 327 |
+
So you can see I got a java folder now,
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:04,000 --> 00:03:06,000
|
| 331 |
+
and now from where you will get the code?
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:06,000 --> 00:03:09,000
|
| 335 |
+
So first of all, even before we do any configuration,
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:09,000 --> 00:03:11,000
|
| 339 |
+
let's get the code from our Spring Boot project
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:11,000 --> 00:03:15,000
|
| 343 |
+
and put it here and let's see how it fails, okay?
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:15,000 --> 00:03:17,000
|
| 347 |
+
So I will go back to my IDE,
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:17,000 --> 00:03:20,000
|
| 351 |
+
and from here, we are going to get some files.
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:20,000 --> 00:03:21,000
|
| 355 |
+
So first of all we'll get the files,
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:21,000 --> 00:03:23,000
|
| 359 |
+
which is these three files.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:23,000 --> 00:03:24,000
|
| 363 |
+
In fact, we don't need the main code,
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:24,000 --> 00:03:27,000
|
| 367 |
+
we just need Alien and HomeController.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:27,000 --> 00:03:29,000
|
| 371 |
+
So let's get that. Go back to Eclipse.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:29,000 --> 00:03:31,000
|
| 375 |
+
And in this you can see, we don't have a package yet.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:31,000 --> 00:03:33,000
|
| 379 |
+
So let me create a package first.
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:33,000 --> 00:03:36,000
|
| 383 |
+
So in the java folder, I will have the same package name
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:36,000 --> 00:03:37,000
|
| 387 |
+
which we were using earlier,
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:39,000 --> 00:03:44,000
|
| 391 |
+
which is com.telusko.SpringMVCDemo.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:44,000 --> 00:03:47,000
|
| 395 |
+
Of course, we have different end package,
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:03:47,000 --> 00:03:48,000
|
| 399 |
+
but the structure will be same.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:03:48,000 --> 00:03:50,000
|
| 403 |
+
So if we can see we don't have a package here.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:03:50,000 --> 00:03:51,000
|
| 407 |
+
So first of all, before copying this
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:03:51,000 --> 00:03:54,000
|
| 411 |
+
or pasting this, we'll create a package.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:03:54,000 --> 00:03:56,000
|
| 415 |
+
So it's a New, Package,
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:03:56,000 --> 00:04:00,000
|
| 419 |
+
and we'll name this package as com.telusko.SpringMVCDemo.
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:02,000 --> 00:04:03,000
|
| 423 |
+
So you can see we've got our package here,
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:03,000 --> 00:04:06,000
|
| 427 |
+
and it should also give the folder structure in this case.
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:06,000 --> 00:04:10,000
|
| 431 |
+
Okay, now we can simply paste it in this. So paste.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:10,000 --> 00:04:11,000
|
| 435 |
+
And now you can see
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:11,000 --> 00:04:14,000
|
| 439 |
+
you will have those two particular files there.
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:14,000 --> 00:04:16,000
|
| 443 |
+
We got Alien, and we got HomeController.
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:17,000 --> 00:04:19,000
|
| 447 |
+
Okay, nothing fancy, simple stuff,
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:19,000 --> 00:04:21,000
|
| 451 |
+
but we just have to make sure
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:21,000 --> 00:04:25,000
|
| 455 |
+
that we use a proper packaging now, which is SpringBootDemo,
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:25,000 --> 00:04:27,000
|
| 459 |
+
I mean SpringMVCDemo, not boot, done.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:27,000 --> 00:04:29,000
|
| 463 |
+
So you can see we got the packages,
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:29,000 --> 00:04:31,000
|
| 467 |
+
but if you go back to the HomeController,
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:31,000 --> 00:04:33,000
|
| 471 |
+
there are lot of errors here.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:33,000 --> 00:04:36,000
|
| 475 |
+
And what are the errors? It says Jakarta not found, okay?
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:36,000 --> 00:04:38,000
|
| 479 |
+
In fact, we don't even need this servlet code,
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:38,000 --> 00:04:39,000
|
| 483 |
+
or do we have?
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:04:39,000 --> 00:04:43,000
|
| 487 |
+
HttpServlet is used nowhere. We can remove that.
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:04:43,000 --> 00:04:45,000
|
| 491 |
+
Next we want this Spring Framework.
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:04:45,000 --> 00:04:48,000
|
| 495 |
+
And in this project we don't have Spring Framework.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:04:48,000 --> 00:04:49,000
|
| 499 |
+
So we'll do that in some time.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:04:49,000 --> 00:04:52,000
|
| 503 |
+
Next, I want to make sure that I get my JSP files.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:04:52,000 --> 00:04:56,000
|
| 507 |
+
So if you can see, we do have a webapp folder here, webapp.
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:04:56,000 --> 00:04:59,000
|
| 511 |
+
Inside this, I want to paste my JSP files.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:04:59,000 --> 00:05:03,000
|
| 515 |
+
So if you can go back here, pick up the views folder itself
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:05:03,000 --> 00:05:04,000
|
| 519 |
+
and paste in this webapp.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:05:04,000 --> 00:05:06,000
|
| 523 |
+
And you can see we got views here.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:05:06,000 --> 00:05:08,000
|
| 527 |
+
Some issue with the Eclipse, doesn't matter.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:05:08,000 --> 00:05:10,000
|
| 531 |
+
We'll see if this works or not.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:05:10,000 --> 00:05:11,000
|
| 535 |
+
But we ought to make sure,
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:05:11,000 --> 00:05:13,000
|
| 539 |
+
I mean we have copied the important files, right?
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:05:13,000 --> 00:05:15,000
|
| 543 |
+
Apart from this, there's no other file we have to copy.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:05:15,000 --> 00:05:17,000
|
| 547 |
+
Of course you can get CSS,
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:05:17,000 --> 00:05:19,000
|
| 551 |
+
but in this particular section we'll skip CSS,
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:05:19,000 --> 00:05:21,000
|
| 555 |
+
because it needs additional configuration.
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:05:21,000 --> 00:05:24,000
|
| 559 |
+
And our motto is not to build beautiful UI here, right?
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:05:24,000 --> 00:05:27,000
|
| 563 |
+
Our motto here is to build a better backend.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:05:27,000 --> 00:05:28,000
|
| 567 |
+
In the application.properties,
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:05:28,000 --> 00:05:29,000
|
| 571 |
+
we don't have to set anything here,
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:05:29,000 --> 00:05:31,000
|
| 575 |
+
because in the Spring MVC project,
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:05:31,000 --> 00:05:33,000
|
| 579 |
+
we are not going to use property files.
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:05:33,000 --> 00:05:37,000
|
| 583 |
+
We'll be using the old pattern of XML files, we'll use that.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:05:37,000 --> 00:05:39,000
|
| 587 |
+
Next we have to get the dependencies.
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:05:39,000 --> 00:05:42,000
|
| 591 |
+
And you can see, here, we have used the Jasper
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:05:42,000 --> 00:05:47,000
|
| 595 |
+
to convert the JSPs and we got the spring-boot-starter-web.
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:05:48,000 --> 00:05:50,000
|
| 599 |
+
Anything else we need? Nothing.
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:05:50,000 --> 00:05:52,000
|
| 603 |
+
But then we are not going to use the Spring Boot, right?
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:05:52,000 --> 00:05:54,000
|
| 607 |
+
So what dependency I need?
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:05:54,000 --> 00:05:57,000
|
| 611 |
+
So we need three dependencies first of all.
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:05:57,000 --> 00:05:59,000
|
| 615 |
+
Depend upon which Tomcat version you're using.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:05:59,000 --> 00:06:01,000
|
| 619 |
+
If you are working with Tomcat 9,
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:06:01,000 --> 00:06:04,000
|
| 623 |
+
you might not need the JSTL dependency.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:06:04,000 --> 00:06:06,000
|
| 627 |
+
But let's start with the first one.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:06:06,000 --> 00:06:08,000
|
| 631 |
+
The first dependency you need is Spring Framework,
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:06:08,000 --> 00:06:11,000
|
| 635 |
+
but then Spring MVC, actually not framework.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:06:11,000 --> 00:06:14,000
|
| 639 |
+
So when you search for Spring MVC, this is what you need.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:06:14,000 --> 00:06:16,000
|
| 643 |
+
Spring Web MVC, click on this,
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:06:16,000 --> 00:06:19,000
|
| 647 |
+
and you can get this one, 6.1.0,
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:06:19,000 --> 00:06:20,000
|
| 651 |
+
depending on when you're watching this.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:06:20,000 --> 00:06:24,000
|
| 655 |
+
If you're watching after some time, pick up the second last
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:06:24,000 --> 00:06:27,000
|
| 659 |
+
or third last one, which has a more usage.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:06:27,000 --> 00:06:31,000
|
| 663 |
+
So click on 6.1.0, get this dependency.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:06:31,000 --> 00:06:33,000
|
| 667 |
+
And in the Eclipse, make sure
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:06:33,000 --> 00:06:36,000
|
| 671 |
+
that you go to your pom.xml file.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:06:36,000 --> 00:06:39,000
|
| 675 |
+
And inside this, just add this dependency.
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:06:39,000 --> 00:06:40,000
|
| 679 |
+
So that's the first dependency we need,
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:06:40,000 --> 00:06:42,000
|
| 683 |
+
which is for Spring MVC.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:06:42,000 --> 00:06:45,000
|
| 687 |
+
And the moment you do that in the Eclipse,
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:06:45,000 --> 00:06:49,000
|
| 691 |
+
if you see the libraries here in the Maven Dependencies,
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:06:49,000 --> 00:06:51,000
|
| 695 |
+
you will get all the Spring dependencies.
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:06:51,000 --> 00:06:51,000
|
| 699 |
+
That's the first step.
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:06:51,000 --> 00:06:54,000
|
| 703 |
+
And if you go back to HomeController,
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:06:54,000 --> 00:06:56,000
|
| 707 |
+
you can see we don't have any errors now.
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:06:56,000 --> 00:06:58,000
|
| 711 |
+
We got all the things which are needed.
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:06:58,000 --> 00:07:00,000
|
| 715 |
+
Okay, that's good. So that's it.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:07:00,000 --> 00:07:03,000
|
| 719 |
+
You know, we got the pages, we got the Java code,
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:07:03,000 --> 00:07:05,000
|
| 723 |
+
and we also got the dependency.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:07:05,000 --> 00:07:06,000
|
| 727 |
+
Let's see if this works,
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:07:06,000 --> 00:07:08,000
|
| 731 |
+
and if it fails, let's see, how do we solve it?
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:07:08,000 --> 00:07:11,000
|
| 735 |
+
But before running this, we have to make sure
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:07:11,000 --> 00:07:13,000
|
| 739 |
+
that in your Eclipse we have a server.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:07:13,000 --> 00:07:14,000
|
| 743 |
+
Because when you try to run this,
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:07:14,000 --> 00:07:15,000
|
| 747 |
+
how would you run this project?
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:07:15,000 --> 00:07:17,000
|
| 751 |
+
If you say right click here, and Run As,
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:07:17,000 --> 00:07:19,000
|
| 755 |
+
if you click on Run on Server,
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:07:19,000 --> 00:07:22,000
|
| 759 |
+
we don't have a server here, we have to connect it.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:07:22,000 --> 00:07:24,000
|
| 763 |
+
So how do we do that? Simple step.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:07:24,000 --> 00:07:27,000
|
| 767 |
+
You can click on this no server,
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:07:27,000 --> 00:07:29,000
|
| 771 |
+
but we'll see that in the next video,
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:07:29,000 --> 00:07:30,000
|
| 775 |
+
how do you set up a Tomcat here.
|
| 776 |
+
|
13 - Exploring Web MVC without Spring Boot/002 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.2%20Creating%20a%20Spring%20MVC%20Project_1
|
13 - Exploring Web MVC without Spring Boot/003 Running Tomcat in Eclipse_en.srt
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:04,000
|
| 7 |
+
-: Now, let's see,
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:04,000 --> 00:00:06,000
|
| 11 |
+
how do you set up a Tomcat in Eclipse
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:06,000 --> 00:00:08,000
|
| 15 |
+
and how do you connect your project to that Tomcat?
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:08,000 --> 00:00:10,000
|
| 19 |
+
So if you go to the Servers tabs here,
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:10,000 --> 00:00:12,000
|
| 23 |
+
you can click on "No servers are available".
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:12,000 --> 00:00:13,000
|
| 27 |
+
It will give you a prompt.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:13,000 --> 00:00:14,000
|
| 31 |
+
Now, we have to add a server.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:14,000 --> 00:00:17,000
|
| 35 |
+
Now you can select the server which you want to add.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:17,000 --> 00:00:19,000
|
| 39 |
+
This time we want to go for Tomcat.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:19,000 --> 00:00:21,000
|
| 43 |
+
So I will click on Apache and scroll down.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:21,000 --> 00:00:24,000
|
| 47 |
+
We are going for Tomcat v10.1, click next.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:24,000 --> 00:00:27,000
|
| 51 |
+
Now this is where you have to select a path
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:27,000 --> 00:00:29,000
|
| 55 |
+
where you have your Tomcat downloaded.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:29,000 --> 00:00:30,000
|
| 59 |
+
If you don't have a downloaded version,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:30,000 --> 00:00:33,000
|
| 63 |
+
you can click on Download and install, even that works.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:33,000 --> 00:00:35,000
|
| 67 |
+
But I have a setup, so we click on browse.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:35,000 --> 00:00:37,000
|
| 71 |
+
And just navigate to Tomcat.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:37,000 --> 00:00:40,000
|
| 75 |
+
So basically search for this particular folder.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:40,000 --> 00:00:41,000
|
| 79 |
+
So I have it in my downloads.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:41,000 --> 00:00:44,000
|
| 83 |
+
You can just get it from the path, select the path,
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:44,000 --> 00:00:46,000
|
| 87 |
+
and click on Next.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:46,000 --> 00:00:47,000
|
| 91 |
+
Do you want to, so it will ask you,
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:47,000 --> 00:00:49,000
|
| 95 |
+
do you want to add any project to your Tomcat?
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:49,000 --> 00:00:52,000
|
| 99 |
+
If you don't do that, so your Tomcat will run,
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:52,000 --> 00:00:53,000
|
| 103 |
+
but not your project.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:53,000 --> 00:00:57,000
|
| 107 |
+
So we can shift our project inside this and click on Finish.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:00:57,000 --> 00:01:00,000
|
| 111 |
+
So now we have a Tomcat, which is in Stopped stage.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:00,000 --> 00:01:03,000
|
| 115 |
+
But if we expand this, we have a Spring project there.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:03,000 --> 00:01:07,000
|
| 119 |
+
And if you start this Tomcat, let's see if that works.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:07,000 --> 00:01:08,000
|
| 123 |
+
I will click on start.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:08,000 --> 00:01:10,000
|
| 127 |
+
Okay, it says it's already in use.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:10,000 --> 00:01:14,000
|
| 131 |
+
It's because in the IntelliJ, I have not stopped it.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:14,000 --> 00:01:15,000
|
| 135 |
+
We are using the same port number.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:15,000 --> 00:01:17,000
|
| 139 |
+
If you want to change the port number, you can do that.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:17,000 --> 00:01:18,000
|
| 143 |
+
But here I don't want to do that.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:18,000 --> 00:01:20,000
|
| 147 |
+
So I will just, you can see we have an icon here.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:20,000 --> 00:01:22,000
|
| 151 |
+
Restart the server, Relaunch.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:22,000 --> 00:01:24,000
|
| 155 |
+
Okay, we'll start it from here
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:25,000 --> 00:01:27,000
|
| 159 |
+
and you can see the Tomcat started.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:27,000 --> 00:01:29,000
|
| 163 |
+
Okay, so that's good,
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:29,000 --> 00:01:30,000
|
| 167 |
+
but now we have to run the project.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:30,000 --> 00:01:32,000
|
| 171 |
+
So I will just right-click here.
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:32,000 --> 00:01:34,000
|
| 175 |
+
Say Run As, Run on Server.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:34,000 --> 00:01:36,000
|
| 179 |
+
We already have a Tomcat server here.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:36,000 --> 00:01:40,000
|
| 183 |
+
Click on Next, Finish, and boom.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:40,000 --> 00:01:43,000
|
| 187 |
+
So you can see, it has opened a browser for us.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:43,000 --> 00:01:45,000
|
| 191 |
+
I'll be using my own browser.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:45,000 --> 00:01:49,000
|
| 195 |
+
And the URL is localhost:8080, enter.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:49,000 --> 00:01:50,000
|
| 199 |
+
It's not working.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:50,000 --> 00:01:51,000
|
| 203 |
+
Something is not working.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:51,000 --> 00:01:52,000
|
| 207 |
+
Okay, what is that?
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:52,000 --> 00:01:55,000
|
| 211 |
+
So let's search if it is working,
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:55,000 --> 00:01:56,000
|
| 215 |
+
you can see it is not working.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:01:56,000 --> 00:01:59,000
|
| 219 |
+
It says "resource is not available".
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:01:59,000 --> 00:02:00,000
|
| 223 |
+
Okay, so it is not working.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:00,000 --> 00:02:03,000
|
| 227 |
+
But why? Let's understand that in the next video.
|
| 228 |
+
|
13 - Exploring Web MVC without Spring Boot/003 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.3%20Running%20Tomcat%20in%20Eclipse
|
13 - Exploring Web MVC without Spring Boot/004 Dispatcher Servlet_en.srt
ADDED
|
@@ -0,0 +1,812 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: So, we have created this project off SpringMVC,
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:07,000
|
| 11 |
+
and that is a Maven project, right?
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:09,000
|
| 15 |
+
And then, when we were trying to run the project,
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:09,000 --> 00:00:10,000
|
| 19 |
+
it is not working.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:10,000 --> 00:00:12,000
|
| 23 |
+
Now, mind you, we do have a controller.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:12,000 --> 00:00:15,000
|
| 27 |
+
So if you see the code, we do have a controller here,
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:15,000 --> 00:00:16,000
|
| 31 |
+
which is HomeController.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:16,000 --> 00:00:20,000
|
| 35 |
+
And then, we do have a mapping for the homepage.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:20,000 --> 00:00:22,000
|
| 39 |
+
It should return the index.jsp,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:22,000 --> 00:00:25,000
|
| 43 |
+
but what you got here is not found.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:25,000 --> 00:00:26,000
|
| 47 |
+
What went wrong here?
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:26,000 --> 00:00:29,000
|
| 51 |
+
See, the thing is, this is not a Spring Boot project.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:29,000 --> 00:00:31,000
|
| 55 |
+
This is a normal Maven project.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:31,000 --> 00:00:34,000
|
| 59 |
+
Now even if you added your Spring dependencies here,
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:34,000 --> 00:00:37,000
|
| 63 |
+
your Maven has no idea that it has to call
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:37,000 --> 00:00:38,000
|
| 67 |
+
this particular controller.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:38,000 --> 00:00:40,000
|
| 71 |
+
It's because in this Maven project,
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:40,000 --> 00:00:42,000
|
| 75 |
+
which we are running on Tomcat,
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:42,000 --> 00:00:44,000
|
| 79 |
+
now Tomcat being a Servlet Container,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:44,000 --> 00:00:47,000
|
| 83 |
+
it is responsible to run the servlets.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:47,000 --> 00:00:49,000
|
| 87 |
+
But then there has to be mapping, right?
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:49,000 --> 00:00:53,000
|
| 91 |
+
So there have to be a mapping for a request and a servlet.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:53,000 --> 00:00:54,000
|
| 95 |
+
And we are not doing that.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:54,000 --> 00:00:56,000
|
| 99 |
+
Of course, we will say there is a controller,
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:56,000 --> 00:00:59,000
|
| 103 |
+
but then your Tomcat has no idea.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:59,000 --> 00:01:00,000
|
| 107 |
+
The thing is, in Spring Framework,
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:00,000 --> 00:01:02,000
|
| 111 |
+
we can have multiple controllers, right?
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:02,000 --> 00:01:04,000
|
| 115 |
+
As I mentioned before, for different requests,
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:04,000 --> 00:01:05,000
|
| 119 |
+
we'll be having different controllers.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:05,000 --> 00:01:07,000
|
| 123 |
+
And to navigate to different controllers,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:07,000 --> 00:01:09,000
|
| 127 |
+
we have our Front controllers.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:09,000 --> 00:01:11,000
|
| 131 |
+
So basically, you have a client,
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:11,000 --> 00:01:13,000
|
| 135 |
+
and then you have a lot of controllers on the other side.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:13,000 --> 00:01:15,000
|
| 139 |
+
But when a client sends a request,
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:15,000 --> 00:01:17,000
|
| 143 |
+
the request will not directly go to a particular controller.
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:17,000 --> 00:01:20,000
|
| 147 |
+
The request will go to something called a Front controller.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:20,000 --> 00:01:22,000
|
| 151 |
+
Now, this sits in between.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:22,000 --> 00:01:24,000
|
| 155 |
+
And your Front controller is responsible
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:24,000 --> 00:01:26,000
|
| 159 |
+
to send a particular request
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:26,000 --> 00:01:27,000
|
| 163 |
+
to a particular controller.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:27,000 --> 00:01:29,000
|
| 167 |
+
So let's say if you request for the homepage,
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:29,000 --> 00:01:31,000
|
| 171 |
+
it is a job of your Front controller to know
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:31,000 --> 00:01:32,000
|
| 175 |
+
that I have a controller here
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:32,000 --> 00:01:35,000
|
| 179 |
+
who can accept the request for the homepage.
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:35,000 --> 00:01:37,000
|
| 183 |
+
Let's say you request for an addition of two numbers.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:37,000 --> 00:01:38,000
|
| 187 |
+
You are saying add.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:38,000 --> 00:01:39,000
|
| 191 |
+
Now, you have a controller there
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:39,000 --> 00:01:41,000
|
| 195 |
+
who is responsible to add two numbers.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:41,000 --> 00:01:43,000
|
| 199 |
+
Now, your front controller will know that,
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:43,000 --> 00:01:45,000
|
| 203 |
+
hey, we have a controller there who can add two numbers
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:45,000 --> 00:01:47,000
|
| 207 |
+
with a request "add".
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:47,000 --> 00:01:48,000
|
| 211 |
+
Now, this controller,
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:48,000 --> 00:01:50,000
|
| 215 |
+
the Front controller in Spring Framework
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:01:50,000 --> 00:01:53,000
|
| 219 |
+
is called a DispatcherServlet.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:01:53,000 --> 00:01:56,000
|
| 223 |
+
So this is the first servlet which you have to go to.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:01:56,000 --> 00:01:59,000
|
| 227 |
+
And then this will navigate to different controllers.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:01:59,000 --> 00:02:01,000
|
| 231 |
+
Now, in this project, we do have a controller,
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:01,000 --> 00:02:03,000
|
| 235 |
+
but we don't have a DispatcherServlet.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:03,000 --> 00:02:07,000
|
| 239 |
+
Now, do we have to create our own DispatcherServlet? No.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:07,000 --> 00:02:08,000
|
| 243 |
+
Basically, Spring says,
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:08,000 --> 00:02:10,000
|
| 247 |
+
don't worry, I do have a DispatcherServlet,
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:10,000 --> 00:02:11,000
|
| 251 |
+
you just have to configure it.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:11,000 --> 00:02:13,000
|
| 255 |
+
So you have to tell your Tomcat,
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:13,000 --> 00:02:15,000
|
| 259 |
+
hey, you know, every time you send a request,
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:15,000 --> 00:02:18,000
|
| 263 |
+
send the request to the DispatcherServlet.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:18,000 --> 00:02:19,000
|
| 267 |
+
DispatcherServlet will take care
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:19,000 --> 00:02:21,000
|
| 271 |
+
of the remaining operations.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:21,000 --> 00:02:22,000
|
| 275 |
+
Now, how will you configure that?
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:22,000 --> 00:02:25,000
|
| 279 |
+
Now see, one of the file which goes,
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:25,000 --> 00:02:26,000
|
| 283 |
+
I mean every time you run this project,
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:26,000 --> 00:02:29,000
|
| 287 |
+
your Tomcat goes to one file,
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:29,000 --> 00:02:31,000
|
| 291 |
+
which is the web.xml.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:31,000 --> 00:02:32,000
|
| 295 |
+
Now, this is where you have to mention,
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:32,000 --> 00:02:33,000
|
| 299 |
+
hey, you know, when you send a request,
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:33,000 --> 00:02:36,000
|
| 303 |
+
send request to this particular servlet.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:02:36,000 --> 00:02:39,000
|
| 307 |
+
And the way you do that is by providing two tags.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:02:39,000 --> 00:02:43,000
|
| 311 |
+
So basically the first tag is the servlet tag
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:02:43,000 --> 00:02:47,000
|
| 315 |
+
and the second one is the servlet-mapping tag.
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:02:47,000 --> 00:02:49,000
|
| 319 |
+
So basically, we have to use this too,
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:02:49,000 --> 00:02:51,000
|
| 323 |
+
which is servlet tag and servlet-mapping tag.
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:02:51,000 --> 00:02:53,000
|
| 327 |
+
Now, in this servlet mapping,
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:02:53,000 --> 00:02:57,000
|
| 331 |
+
basically this is where you mention the url-pattern.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:02:57,000 --> 00:02:59,000
|
| 335 |
+
So you can say for all the requests,
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:02:59,000 --> 00:03:01,000
|
| 339 |
+
doesn't matter what request we are getting.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:01,000 --> 00:03:03,000
|
| 343 |
+
For all the requests,
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:03,000 --> 00:03:05,000
|
| 347 |
+
send the request to this particular servlet.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:05,000 --> 00:03:07,000
|
| 351 |
+
Now, which servlet I am talking about?
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:07,000 --> 00:03:10,000
|
| 355 |
+
I'm talking about the DispatcherServlet.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:10,000 --> 00:03:11,000
|
| 359 |
+
Now, how do you get DispatcherServlet?
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:11,000 --> 00:03:13,000
|
| 363 |
+
So, if you go to your dependency,
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:13,000 --> 00:03:14,000
|
| 367 |
+
of course, I know the full name,
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:14,000 --> 00:03:16,000
|
| 371 |
+
but if you want to know the full name,
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:16,000 --> 00:03:18,000
|
| 375 |
+
even we can forgot that, right?
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:18,000 --> 00:03:20,000
|
| 379 |
+
So if you expand your Maven Dependencies,
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:20,000 --> 00:03:22,000
|
| 383 |
+
we see something called webmvc.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:22,000 --> 00:03:24,000
|
| 387 |
+
If you expand this,
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:24,000 --> 00:03:28,000
|
| 391 |
+
there's something called "org.springframework.web.servlet."
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:28,000 --> 00:03:29,000
|
| 395 |
+
And if you expand this,
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:03:29,000 --> 00:03:32,000
|
| 399 |
+
you will find a DispatcherServlet here.
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:03:32,000 --> 00:03:34,000
|
| 403 |
+
This is the class you have to use.
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:03:34,000 --> 00:03:38,000
|
| 407 |
+
So I can simply copy the qualified name for it
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:03:38,000 --> 00:03:42,000
|
| 411 |
+
and paste it here without the ".class" extension.
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:03:42,000 --> 00:03:42,000
|
| 415 |
+
And that's done.
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:03:42,000 --> 00:03:44,000
|
| 419 |
+
So what we are saying is,
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:03:44,000 --> 00:03:46,000
|
| 423 |
+
every time someone sends a request for the url-mapping
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:03:46,000 --> 00:03:49,000
|
| 427 |
+
or this particular URL, which is the homepage,
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:03:49,000 --> 00:03:52,000
|
| 431 |
+
you have to call the DispatcherServlet.
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:03:52,000 --> 00:03:54,000
|
| 435 |
+
In fact, not just the homepage, any request.
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:03:54,000 --> 00:03:56,000
|
| 439 |
+
But then to map these two,
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:03:56,000 --> 00:03:57,000
|
| 443 |
+
basically there are different tags, right?
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:03:57,000 --> 00:04:00,000
|
| 447 |
+
Servlet and servlet-mapping are two different tags.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:00,000 --> 00:04:01,000
|
| 451 |
+
If you want to connect these two,
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:01,000 --> 00:04:03,000
|
| 455 |
+
you have to add one more tag here,
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:03,000 --> 00:04:06,000
|
| 459 |
+
which is your servlet-name.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:06,000 --> 00:04:07,000
|
| 463 |
+
Of course, you can name anything here.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:07,000 --> 00:04:09,000
|
| 467 |
+
I can say "dispatcher" or I can say "telusko".
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:09,000 --> 00:04:12,000
|
| 471 |
+
Let's say I'm going for the servlet name as "telusko".
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:12,000 --> 00:04:14,000
|
| 475 |
+
And here also, you have to do the same thing,
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:14,000 --> 00:04:16,000
|
| 479 |
+
"<servlet-name>telusko".
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:16,000 --> 00:04:18,000
|
| 483 |
+
You have to make sure these two are the same
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:04:18,000 --> 00:04:20,000
|
| 487 |
+
because you can have multiple servlet tags
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:04:20,000 --> 00:04:21,000
|
| 491 |
+
in this particular file
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:04:21,000 --> 00:04:23,000
|
| 495 |
+
for different URL or mapping.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:04:23,000 --> 00:04:26,000
|
| 499 |
+
But at this point, I want to make sure that I only have one.
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:04:26,000 --> 00:04:30,000
|
| 503 |
+
So for all of the requests, call the display servlet.
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:04:30,000 --> 00:04:33,000
|
| 507 |
+
And to map these two, we have to use "telusko", "telusko".
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:04:33,000 --> 00:04:35,000
|
| 511 |
+
Okay, now we have done the mapping.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:04:35,000 --> 00:04:37,000
|
| 515 |
+
Now we are saying, hey Tomcat,
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:04:37,000 --> 00:04:38,000
|
| 519 |
+
every time you get a request,
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:04:38,000 --> 00:04:40,000
|
| 523 |
+
send the request to the DispatcherServlet.
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:04:40,000 --> 00:04:43,000
|
| 527 |
+
DispatcherServlet will take care of the other operations.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:04:43,000 --> 00:04:45,000
|
| 531 |
+
I hope this time this will work now.
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:04:45,000 --> 00:04:47,000
|
| 535 |
+
Let's run this application.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:04:47,000 --> 00:04:49,000
|
| 539 |
+
You can see there is no problem.
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:04:49,000 --> 00:04:50,000
|
| 543 |
+
Tomcat started.
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:04:50,000 --> 00:04:53,000
|
| 547 |
+
So let me go to the browser and run.
|
| 548 |
+
|
| 549 |
+
138
|
| 550 |
+
00:04:53,000 --> 00:04:55,000
|
| 551 |
+
Okay, I think I missed one more.
|
| 552 |
+
|
| 553 |
+
139
|
| 554 |
+
00:04:55,000 --> 00:04:56,000
|
| 555 |
+
Let me just change the configuration,
|
| 556 |
+
|
| 557 |
+
140
|
| 558 |
+
00:04:56,000 --> 00:04:57,000
|
| 559 |
+
this is still not working.
|
| 560 |
+
|
| 561 |
+
141
|
| 562 |
+
00:04:57,000 --> 00:04:58,000
|
| 563 |
+
So I will go to the Build Path.
|
| 564 |
+
|
| 565 |
+
142
|
| 566 |
+
00:04:58,000 --> 00:05:02,000
|
| 567 |
+
I'm not sure if it is accepting our Tomcat data.
|
| 568 |
+
|
| 569 |
+
143
|
| 570 |
+
00:05:02,000 --> 00:05:02,000
|
| 571 |
+
We'll go to library.
|
| 572 |
+
|
| 573 |
+
144
|
| 574 |
+
00:05:02,000 --> 00:05:05,000
|
| 575 |
+
Okay, so we have forgot to add the Tomcat library here.
|
| 576 |
+
|
| 577 |
+
145
|
| 578 |
+
00:05:05,000 --> 00:05:07,000
|
| 579 |
+
So sometimes, if it doesn't work,
|
| 580 |
+
|
| 581 |
+
146
|
| 582 |
+
00:05:07,000 --> 00:05:09,000
|
| 583 |
+
please check your Build Path.
|
| 584 |
+
|
| 585 |
+
147
|
| 586 |
+
00:05:09,000 --> 00:05:13,000
|
| 587 |
+
So what I did, is I right-clicked on my project,
|
| 588 |
+
|
| 589 |
+
148
|
| 590 |
+
00:05:13,000 --> 00:05:14,000
|
| 591 |
+
go to the Build Path.
|
| 592 |
+
|
| 593 |
+
149
|
| 594 |
+
00:05:14,000 --> 00:05:15,000
|
| 595 |
+
And that's what, you know,
|
| 596 |
+
|
| 597 |
+
150
|
| 598 |
+
00:05:15,000 --> 00:05:17,000
|
| 599 |
+
when you work with normal SpringMVC
|
| 600 |
+
|
| 601 |
+
151
|
| 602 |
+
00:05:17,000 --> 00:05:18,000
|
| 603 |
+
or normal Spring Framework,
|
| 604 |
+
|
| 605 |
+
152
|
| 606 |
+
00:05:18,000 --> 00:05:19,000
|
| 607 |
+
you have to do a lot of configuration.
|
| 608 |
+
|
| 609 |
+
153
|
| 610 |
+
00:05:19,000 --> 00:05:21,000
|
| 611 |
+
And if you're thinking you'll be doing this every time,
|
| 612 |
+
|
| 613 |
+
154
|
| 614 |
+
00:05:21,000 --> 00:05:22,000
|
| 615 |
+
not exactly.
|
| 616 |
+
|
| 617 |
+
155
|
| 618 |
+
00:05:22,000 --> 00:05:24,000
|
| 619 |
+
This configuration will be done only once
|
| 620 |
+
|
| 621 |
+
156
|
| 622 |
+
00:05:24,000 --> 00:05:25,000
|
| 623 |
+
when you start the project.
|
| 624 |
+
|
| 625 |
+
157
|
| 626 |
+
00:05:25,000 --> 00:05:26,000
|
| 627 |
+
So click on library.
|
| 628 |
+
|
| 629 |
+
158
|
| 630 |
+
00:05:26,000 --> 00:05:29,000
|
| 631 |
+
First of all, I will change my Java version to Java 21
|
| 632 |
+
|
| 633 |
+
159
|
| 634 |
+
00:05:29,000 --> 00:05:30,000
|
| 635 |
+
because that's what I'm using.
|
| 636 |
+
|
| 637 |
+
160
|
| 638 |
+
00:05:30,000 --> 00:05:31,000
|
| 639 |
+
Finish.
|
| 640 |
+
|
| 641 |
+
161
|
| 642 |
+
00:05:31,000 --> 00:05:35,000
|
| 643 |
+
And then here, I want to add the Runtime as well.
|
| 644 |
+
|
| 645 |
+
162
|
| 646 |
+
00:05:35,000 --> 00:05:36,000
|
| 647 |
+
Just on the safer side.
|
| 648 |
+
|
| 649 |
+
163
|
| 650 |
+
00:05:36,000 --> 00:05:38,000
|
| 651 |
+
Click on Apply and Close.
|
| 652 |
+
|
| 653 |
+
164
|
| 654 |
+
00:05:38,000 --> 00:05:40,000
|
| 655 |
+
Let's see if this works now.
|
| 656 |
+
|
| 657 |
+
165
|
| 658 |
+
00:05:40,000 --> 00:05:42,000
|
| 659 |
+
Restart the server, go back, refresh.
|
| 660 |
+
|
| 661 |
+
166
|
| 662 |
+
00:05:42,000 --> 00:05:43,000
|
| 663 |
+
Still not working.
|
| 664 |
+
|
| 665 |
+
167
|
| 666 |
+
00:05:43,000 --> 00:05:45,000
|
| 667 |
+
Okay, so now when I'm running this,
|
| 668 |
+
|
| 669 |
+
168
|
| 670 |
+
00:05:45,000 --> 00:05:48,000
|
| 671 |
+
there was some issue with the cashier or something.
|
| 672 |
+
|
| 673 |
+
169
|
| 674 |
+
00:05:48,000 --> 00:05:50,000
|
| 675 |
+
So you can see when I run this now,
|
| 676 |
+
|
| 677 |
+
170
|
| 678 |
+
00:05:50,000 --> 00:05:51,000
|
| 679 |
+
we got a different error.
|
| 680 |
+
|
| 681 |
+
171
|
| 682 |
+
00:05:51,000 --> 00:05:53,000
|
| 683 |
+
So this time you're not getting 404.
|
| 684 |
+
|
| 685 |
+
172
|
| 686 |
+
00:05:53,000 --> 00:05:54,000
|
| 687 |
+
That means it was able to find it.
|
| 688 |
+
|
| 689 |
+
173
|
| 690 |
+
00:05:54,000 --> 00:05:56,000
|
| 691 |
+
We got a different error, which is the 500.
|
| 692 |
+
|
| 693 |
+
174
|
| 694 |
+
00:05:56,000 --> 00:05:59,000
|
| 695 |
+
It says "Internal Server Error".
|
| 696 |
+
|
| 697 |
+
175
|
| 698 |
+
00:05:59,000 --> 00:06:01,000
|
| 699 |
+
Now, if you read the error
|
| 700 |
+
|
| 701 |
+
176
|
| 702 |
+
00:06:01,000 --> 00:06:03,000
|
| 703 |
+
and that's what you do when you get the errors, right?
|
| 704 |
+
|
| 705 |
+
177
|
| 706 |
+
00:06:03,000 --> 00:06:06,000
|
| 707 |
+
So it says, if you see the Root Cause,
|
| 708 |
+
|
| 709 |
+
178
|
| 710 |
+
00:06:06,000 --> 00:06:09,000
|
| 711 |
+
it says there is a problem with the IOException
|
| 712 |
+
|
| 713 |
+
179
|
| 714 |
+
00:06:09,000 --> 00:06:10,000
|
| 715 |
+
with the XML file.
|
| 716 |
+
|
| 717 |
+
180
|
| 718 |
+
00:06:10,000 --> 00:06:12,000
|
| 719 |
+
It's because it is not able to.
|
| 720 |
+
|
| 721 |
+
181
|
| 722 |
+
00:06:12,000 --> 00:06:16,000
|
| 723 |
+
I mean, from this file, which is called telusko-servlet.xml.
|
| 724 |
+
|
| 725 |
+
182
|
| 726 |
+
00:06:16,000 --> 00:06:17,000
|
| 727 |
+
Okay, now this is weird
|
| 728 |
+
|
| 729 |
+
183
|
| 730 |
+
00:06:17,000 --> 00:06:19,000
|
| 731 |
+
because we don't even have this file
|
| 732 |
+
|
| 733 |
+
184
|
| 734 |
+
00:06:19,000 --> 00:06:21,000
|
| 735 |
+
and if you go down it actually says
|
| 736 |
+
|
| 737 |
+
185
|
| 738 |
+
00:06:21,000 --> 00:06:23,000
|
| 739 |
+
you don't have this file.
|
| 740 |
+
|
| 741 |
+
186
|
| 742 |
+
00:06:23,000 --> 00:06:25,000
|
| 743 |
+
But why do we need this file?
|
| 744 |
+
|
| 745 |
+
187
|
| 746 |
+
00:06:25,000 --> 00:06:28,000
|
| 747 |
+
I mean that's crazy, right? We got the DispatcherServlet.
|
| 748 |
+
|
| 749 |
+
188
|
| 750 |
+
00:06:28,000 --> 00:06:30,000
|
| 751 |
+
It should send the request to DispatcherServlet.
|
| 752 |
+
|
| 753 |
+
189
|
| 754 |
+
00:06:30,000 --> 00:06:31,000
|
| 755 |
+
And you know what?
|
| 756 |
+
|
| 757 |
+
190
|
| 758 |
+
00:06:31,000 --> 00:06:34,000
|
| 759 |
+
It is actually sending the request to the DispatcherServlet.
|
| 760 |
+
|
| 761 |
+
191
|
| 762 |
+
00:06:34,000 --> 00:06:36,000
|
| 763 |
+
But DispatcherServlet has its own problem.
|
| 764 |
+
|
| 765 |
+
192
|
| 766 |
+
00:06:36,000 --> 00:06:37,000
|
| 767 |
+
DispatcherServlet says, if you want me to work,
|
| 768 |
+
|
| 769 |
+
193
|
| 770 |
+
00:06:37,000 --> 00:06:40,000
|
| 771 |
+
and if you want me to understand different controllers
|
| 772 |
+
|
| 773 |
+
194
|
| 774 |
+
00:06:40,000 --> 00:06:43,000
|
| 775 |
+
and mapping, you have to configure me.
|
| 776 |
+
|
| 777 |
+
195
|
| 778 |
+
00:06:43,000 --> 00:06:46,000
|
| 779 |
+
Of course, we were expecting that the DispatcherServlet
|
| 780 |
+
|
| 781 |
+
196
|
| 782 |
+
00:06:46,000 --> 00:06:50,000
|
| 783 |
+
will be a magician to know all the controllers, but not.
|
| 784 |
+
|
| 785 |
+
197
|
| 786 |
+
00:06:50,000 --> 00:06:51,000
|
| 787 |
+
We have to configure that as well.
|
| 788 |
+
|
| 789 |
+
198
|
| 790 |
+
00:06:51,000 --> 00:06:53,000
|
| 791 |
+
And how do you configure?
|
| 792 |
+
|
| 793 |
+
199
|
| 794 |
+
00:06:53,000 --> 00:06:55,000
|
| 795 |
+
How do you talk to dispatch servlet?
|
| 796 |
+
|
| 797 |
+
200
|
| 798 |
+
00:06:55,000 --> 00:06:57,000
|
| 799 |
+
And that's where we have to create this file,
|
| 800 |
+
|
| 801 |
+
201
|
| 802 |
+
00:06:57,000 --> 00:06:59,000
|
| 803 |
+
which is telusko-servlet.
|
| 804 |
+
|
| 805 |
+
202
|
| 806 |
+
00:06:59,000 --> 00:07:00,000
|
| 807 |
+
How do we do that?
|
| 808 |
+
|
| 809 |
+
203
|
| 810 |
+
00:07:00,000 --> 00:07:01,000
|
| 811 |
+
Let's see in the next video.
|
| 812 |
+
|
13 - Exploring Web MVC without Spring Boot/004 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:06,000
|
| 7 |
+
-: It's time to configure our DispatcherServlet.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:06,000 --> 00:00:08,000
|
| 11 |
+
And the way you do that, the way you talk
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:08,000 --> 00:00:10,000
|
| 15 |
+
to a DispatcherServlet is with the help of this file.
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:10,000 --> 00:00:12,000
|
| 19 |
+
See, there are multiple ways of doing this.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:12,000 --> 00:00:15,000
|
| 23 |
+
You can also use the Java based configuration
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:15,000 --> 00:00:18,000
|
| 27 |
+
using annotations, but then we'll be using XML here,
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:18,000 --> 00:00:20,000
|
| 31 |
+
just to understand what happens behind the scene.
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:20,000 --> 00:00:22,000
|
| 35 |
+
Okay, so I will create this file.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:22,000 --> 00:00:25,000
|
| 39 |
+
So this is telusko-servlet.xml.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:25,000 --> 00:00:27,000
|
| 43 |
+
I will create this file. But then where?
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:27,000 --> 00:00:29,000
|
| 47 |
+
The folder is /WEB-INF.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:29,000 --> 00:00:31,000
|
| 51 |
+
This is where it is expecting it to be.
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:31,000 --> 00:00:32,000
|
| 55 |
+
That's the first thing.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:32,000 --> 00:00:35,000
|
| 59 |
+
Second, why it has this name, telusko-servlet?
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:35,000 --> 00:00:37,000
|
| 63 |
+
Why not something else?
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:37,000 --> 00:00:41,000
|
| 67 |
+
It's because if you look at your project, the name
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:41,000 --> 00:00:43,000
|
| 71 |
+
of your servlet we are mentioning as telusko, right?
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:43,000 --> 00:00:46,000
|
| 75 |
+
That's why it says telusko-servlet.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:46,000 --> 00:00:48,000
|
| 79 |
+
If you give a different name, let's say
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:48,000 --> 00:00:51,000
|
| 83 |
+
if you give a name, t1, t2, or whatever you want to,
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:51,000 --> 00:00:55,000
|
| 87 |
+
so it will be that, what the name, -servlet.xml.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:55,000 --> 00:00:57,000
|
| 91 |
+
And that's why we got that particular file.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:57,000 --> 00:01:00,000
|
| 95 |
+
So let's create the file. So I will just right click here.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:00,000 --> 00:01:01,000
|
| 99 |
+
And say, "Hey,
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:01,000 --> 00:01:06,000
|
| 103 |
+
I want to create a new XML file," which is here.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:06,000 --> 00:01:11,000
|
| 107 |
+
Click on Next. Name this file, which is telusko-servlet.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:11,000 --> 00:01:13,000
|
| 111 |
+
And if you Enter, you got your file.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:13,000 --> 00:01:15,000
|
| 115 |
+
And now in this, we have to do the configuration.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:15,000 --> 00:01:17,000
|
| 119 |
+
Now what configuration I'm talking about?
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:17,000 --> 00:01:19,000
|
| 123 |
+
See, basically we are not, we don't have
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:19,000 --> 00:01:22,000
|
| 127 |
+
to actually manually mention each controller.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:22,000 --> 00:01:26,000
|
| 131 |
+
Reason being, we are using annotations here,
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:26,000 --> 00:01:28,000
|
| 135 |
+
you can see we are doing the mapping here.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:28,000 --> 00:01:29,000
|
| 139 |
+
But what if you don't want to do mapping
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:29,000 --> 00:01:31,000
|
| 143 |
+
in the controller or in the class?
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:31,000 --> 00:01:33,000
|
| 147 |
+
In that case, in this particular file,
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:33,000 --> 00:01:34,000
|
| 151 |
+
you have to do all the mapping.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:34,000 --> 00:01:36,000
|
| 155 |
+
For this request, call this particular method,
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:36,000 --> 00:01:39,000
|
| 159 |
+
for this request, call this particular method.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:39,000 --> 00:01:40,000
|
| 163 |
+
And I don't wanna do that, right?
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:40,000 --> 00:01:42,000
|
| 167 |
+
So we do have annotation there.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:42,000 --> 00:01:45,000
|
| 171 |
+
So we just have to mention to your DispatcherServlet
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:45,000 --> 00:01:47,000
|
| 175 |
+
by saying, "Hey, you know, I'm using annotations
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:47,000 --> 00:01:49,000
|
| 179 |
+
on the controllers, just use them."
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:49,000 --> 00:01:51,000
|
| 183 |
+
And the way you can do that is
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:51,000 --> 00:01:52,000
|
| 187 |
+
first of all, you can mention that "Hey, you know,"
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:52,000 --> 00:01:54,000
|
| 191 |
+
you can say, "Hey, DispatcherServlet,"
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:54,000 --> 00:01:59,000
|
| 195 |
+
I can say DS, "Find the classes in this package."
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:59,000 --> 00:02:00,000
|
| 199 |
+
You can mention the package name.
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:00,000 --> 00:02:02,000
|
| 203 |
+
That's the first thing you have to mention.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:02,000 --> 00:02:06,000
|
| 207 |
+
And second, you have to mention that I'm using annotations.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:06,000 --> 00:02:11,000
|
| 211 |
+
So you can say, "I'm using annotations," that's it.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:11,000 --> 00:02:13,000
|
| 215 |
+
DispatcherServlet will know that I have
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:13,000 --> 00:02:15,000
|
| 219 |
+
to find this file in this package,
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:15,000 --> 00:02:16,000
|
| 223 |
+
whatever package you mention here.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:16,000 --> 00:02:19,000
|
| 227 |
+
And then you are saying that I'm using annotations.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:19,000 --> 00:02:20,000
|
| 231 |
+
Will it work? Of course not.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:20,000 --> 00:02:23,000
|
| 235 |
+
You know, this is XML file, not a essay book, right?
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:23,000 --> 00:02:26,000
|
| 239 |
+
This will not work, so this is not how you write a letter
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:26,000 --> 00:02:27,000
|
| 243 |
+
to DispatcherServlet, okay?
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:27,000 --> 00:02:29,000
|
| 247 |
+
But then we have to do the same thing.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:29,000 --> 00:02:31,000
|
| 251 |
+
For that, we have to use some tags.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:31,000 --> 00:02:33,000
|
| 255 |
+
And whenever you use tags in XML,
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:33,000 --> 00:02:36,000
|
| 259 |
+
we have to also define those tags.
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:36,000 --> 00:02:39,000
|
| 263 |
+
So for definition, I don't want to type it, everything,
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:39,000 --> 00:02:41,000
|
| 267 |
+
because a lengthy file, so I do have a file with me.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:41,000 --> 00:02:42,000
|
| 271 |
+
You will find that in resources.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:42,000 --> 00:02:45,000
|
| 275 |
+
So this is the definition for those beans
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:45,000 --> 00:02:47,000
|
| 279 |
+
or to those tags which you are going to use.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:47,000 --> 00:02:51,000
|
| 283 |
+
So let's end this. So this is what we wanted, right?
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:51,000 --> 00:02:53,000
|
| 287 |
+
So this is the bean definition,
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:53,000 --> 00:02:57,000
|
| 291 |
+
and now we can talk to the DispatcherServlet.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:57,000 --> 00:02:59,000
|
| 295 |
+
So the first thing you will mention is component scan.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:59,000 --> 00:03:03,000
|
| 299 |
+
Now you want to mention which package you have
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:03,000 --> 00:03:04,000
|
| 303 |
+
to scan for the components.
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:04,000 --> 00:03:07,000
|
| 307 |
+
So you will say ctx. So what is ctx here? Just context.
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:07,000 --> 00:03:11,000
|
| 311 |
+
You can see we are defining the context definition as well.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:11,000 --> 00:03:12,000
|
| 315 |
+
So that's it, refer with ctx,
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:12,000 --> 00:03:14,000
|
| 319 |
+
and that's what we are mentioning here.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:14,000 --> 00:03:16,000
|
| 323 |
+
So ctx:component-scan, and then the base package, you have
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:16,000 --> 00:03:20,000
|
| 327 |
+
to mention the package name, which is com.telusko here.
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:20,000 --> 00:03:21,000
|
| 331 |
+
You can be specific here,
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:21,000 --> 00:03:23,000
|
| 335 |
+
you can mention the exact package name.
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:23,000 --> 00:03:27,000
|
| 339 |
+
But com.telusko works. And that's the first thing.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:27,000 --> 00:03:30,000
|
| 343 |
+
Next you have to mention that you are using annotations.
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:30,000 --> 00:03:33,000
|
| 347 |
+
And for that, you'll be using annotation-config.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:33,000 --> 00:03:36,000
|
| 351 |
+
In fact, you can also do a self-closing tags here
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:36,000 --> 00:03:37,000
|
| 355 |
+
instead of typing everything.
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:37,000 --> 00:03:39,000
|
| 359 |
+
That's it, these two things you have to mention
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:39,000 --> 00:03:42,000
|
| 363 |
+
that you have to scan the package in this package.
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:42,000 --> 00:03:45,000
|
| 367 |
+
And then you have to use,
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:45,000 --> 00:03:47,000
|
| 371 |
+
I mean we are using annotation configuration, that's it.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:47,000 --> 00:03:49,000
|
| 375 |
+
Now this is how you talk to DispatcherServlet,
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:49,000 --> 00:03:52,000
|
| 379 |
+
not by writing those two lines, but will this work?
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:52,000 --> 00:03:54,000
|
| 383 |
+
Let's try it out. Of course we learn from the errors.
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:03:54,000 --> 00:03:56,000
|
| 387 |
+
So I will just rerun this application,
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:03:56,000 --> 00:03:59,000
|
| 391 |
+
and go back
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:03:59,000 --> 00:04:02,000
|
| 395 |
+
to my code, run.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:04:02,000 --> 00:04:04,000
|
| 399 |
+
Okay, now this time we got a different error,
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:04:04,000 --> 00:04:06,000
|
| 403 |
+
but at least every time we do something,
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:04:06,000 --> 00:04:08,000
|
| 407 |
+
errors are changing, so that's a good thing, right?
|
| 408 |
+
|
| 409 |
+
103
|
| 410 |
+
00:04:08,000 --> 00:04:11,000
|
| 411 |
+
But what is the problem now?
|
| 412 |
+
|
| 413 |
+
104
|
| 414 |
+
00:04:11,000 --> 00:04:13,000
|
| 415 |
+
Is it the DispatcherServlet is not able to find?
|
| 416 |
+
|
| 417 |
+
105
|
| 418 |
+
00:04:13,000 --> 00:04:15,000
|
| 419 |
+
Yes, DispatcherServlet was able
|
| 420 |
+
|
| 421 |
+
106
|
| 422 |
+
00:04:15,000 --> 00:04:17,000
|
| 423 |
+
to find this particular file.
|
| 424 |
+
|
| 425 |
+
107
|
| 426 |
+
00:04:17,000 --> 00:04:20,000
|
| 427 |
+
Now it knows that which package you have to scan,
|
| 428 |
+
|
| 429 |
+
108
|
| 430 |
+
00:04:20,000 --> 00:04:21,000
|
| 431 |
+
which annotation you have to, I mean
|
| 432 |
+
|
| 433 |
+
109
|
| 434 |
+
00:04:21,000 --> 00:04:24,000
|
| 435 |
+
we have been using annotation configuration, what's wrong?
|
| 436 |
+
|
| 437 |
+
110
|
| 438 |
+
00:04:24,000 --> 00:04:25,000
|
| 439 |
+
And if you observe here,
|
| 440 |
+
|
| 441 |
+
111
|
| 442 |
+
00:04:25,000 --> 00:04:29,000
|
| 443 |
+
in the console it says home method called,
|
| 444 |
+
|
| 445 |
+
112
|
| 446 |
+
00:04:29,000 --> 00:04:33,000
|
| 447 |
+
which means it was able to call the controller.
|
| 448 |
+
|
| 449 |
+
113
|
| 450 |
+
00:04:33,000 --> 00:04:37,000
|
| 451 |
+
So we have reached till here, but it's not going after that.
|
| 452 |
+
|
| 453 |
+
114
|
| 454 |
+
00:04:37,000 --> 00:04:39,000
|
| 455 |
+
You know what's going wrong?
|
| 456 |
+
|
| 457 |
+
115
|
| 458 |
+
00:04:39,000 --> 00:04:44,000
|
| 459 |
+
Let's go back to our page and it says 404. That's right.
|
| 460 |
+
|
| 461 |
+
116
|
| 462 |
+
00:04:44,000 --> 00:04:45,000
|
| 463 |
+
But look at the message.
|
| 464 |
+
|
| 465 |
+
117
|
| 466 |
+
00:04:45,000 --> 00:04:48,000
|
| 467 |
+
It says, no endpoint GET, for the GET request,
|
| 468 |
+
|
| 469 |
+
118
|
| 470 |
+
00:04:48,000 --> 00:04:51,000
|
| 471 |
+
and the URL you're searching for is index.
|
| 472 |
+
|
| 473 |
+
119
|
| 474 |
+
00:04:51,000 --> 00:04:55,000
|
| 475 |
+
Now from where we got index? Let's go back.
|
| 476 |
+
|
| 477 |
+
120
|
| 478 |
+
00:04:55,000 --> 00:04:58,000
|
| 479 |
+
We are returning a index.
|
| 480 |
+
|
| 481 |
+
121
|
| 482 |
+
00:04:58,000 --> 00:05:01,000
|
| 483 |
+
DispatcherServlet says, "You are telling me to call index.
|
| 484 |
+
|
| 485 |
+
122
|
| 486 |
+
00:05:01,000 --> 00:05:02,000
|
| 487 |
+
But what is index?"
|
| 488 |
+
|
| 489 |
+
123
|
| 490 |
+
00:05:02,000 --> 00:05:04,000
|
| 491 |
+
If you remember, when we were working
|
| 492 |
+
|
| 493 |
+
124
|
| 494 |
+
00:05:04,000 --> 00:05:08,000
|
| 495 |
+
with this Spring Boot application, we did the same thing.
|
| 496 |
+
|
| 497 |
+
125
|
| 498 |
+
00:05:08,000 --> 00:05:10,000
|
| 499 |
+
We are returning index there,
|
| 500 |
+
|
| 501 |
+
126
|
| 502 |
+
00:05:10,000 --> 00:05:13,000
|
| 503 |
+
but in the property files we have mentioned
|
| 504 |
+
|
| 505 |
+
127
|
| 506 |
+
00:05:13,000 --> 00:05:16,000
|
| 507 |
+
that you have to find the index in this particular folder,
|
| 508 |
+
|
| 509 |
+
128
|
| 510 |
+
00:05:17,000 --> 00:05:20,000
|
| 511 |
+
and the extension for that index is .jsp.
|
| 512 |
+
|
| 513 |
+
129
|
| 514 |
+
00:05:20,000 --> 00:05:23,000
|
| 515 |
+
Nowhere we are doing that in this particular project.
|
| 516 |
+
|
| 517 |
+
130
|
| 518 |
+
00:05:23,000 --> 00:05:26,000
|
| 519 |
+
So that means you have to also configure the resolver.
|
| 520 |
+
|
| 521 |
+
131
|
| 522 |
+
00:05:26,000 --> 00:05:28,000
|
| 523 |
+
Remember when I mentioned that, when you return this,
|
| 524 |
+
|
| 525 |
+
132
|
| 526 |
+
00:05:28,000 --> 00:05:31,000
|
| 527 |
+
behind the scene, it uses something called a resolver.
|
| 528 |
+
|
| 529 |
+
133
|
| 530 |
+
00:05:31,000 --> 00:05:33,000
|
| 531 |
+
So there's something called view resolver, or in full name,
|
| 532 |
+
|
| 533 |
+
134
|
| 534 |
+
00:05:33,000 --> 00:05:36,000
|
| 535 |
+
it is called InternalResourceViewResolver.
|
| 536 |
+
|
| 537 |
+
135
|
| 538 |
+
00:05:36,000 --> 00:05:39,000
|
| 539 |
+
So we have to configure that. Okay, how do we do that?
|
| 540 |
+
|
| 541 |
+
136
|
| 542 |
+
00:05:39,000 --> 00:05:42,000
|
| 543 |
+
How do we configure the InternalResourceViewResolver?
|
| 544 |
+
|
| 545 |
+
137
|
| 546 |
+
00:05:42,000 --> 00:05:44,000
|
| 547 |
+
Let's see that in the next video.
|
| 548 |
+
|
13 - Exploring Web MVC without Spring Boot/005 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.5%20Configuring%20the%20DispatcherServlet
|
13 - Exploring Web MVC without Spring Boot/006 Internal Resource View Resolver_en.srt
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(bright music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:05,000
|
| 7 |
+
-: Now it's time to configure
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:05,000 --> 00:00:08,000
|
| 11 |
+
the Internal Resource View Resolver.
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:08,000 --> 00:00:09,000
|
| 15 |
+
It's because when you return index here,
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:09,000 --> 00:00:12,000
|
| 19 |
+
despite server has no idea where this index is
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:12,000 --> 00:00:14,000
|
| 23 |
+
and what is extension for this, okay.
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:14,000 --> 00:00:17,000
|
| 27 |
+
And the way you do that is again, go back to the the server
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:18,000 --> 00:00:20,000
|
| 31 |
+
teluskoserver.xml because this is where you
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:20,000 --> 00:00:22,000
|
| 35 |
+
talk to your dispatch satellite.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:22,000 --> 00:00:26,000
|
| 39 |
+
Now to configure that, we have to use a bean tag here.
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:26,000 --> 00:00:29,000
|
| 43 |
+
So I have to say bean. Now, which bean I'm talking about?
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:29,000 --> 00:00:31,000
|
| 47 |
+
So let's enter this. Now, which bean I'm talking about?
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:31,000 --> 00:00:34,000
|
| 51 |
+
So there's something called internal resource resolver
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:34,000 --> 00:00:38,000
|
| 55 |
+
and we have to mention the qualified path,
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:38,000 --> 00:00:40,000
|
| 59 |
+
which is the full path for the class.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:40,000 --> 00:00:41,000
|
| 63 |
+
And the way you get that
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:41,000 --> 00:00:43,000
|
| 67 |
+
is if you go back to Maven Dependencies
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:43,000 --> 00:00:44,000
|
| 71 |
+
The same package.
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:44,000 --> 00:00:45,000
|
| 75 |
+
Again, we have to go with this
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:45,000 --> 00:00:50,000
|
| 79 |
+
org.springframework.web.servlet, but a different sub folder.
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:50,000 --> 00:00:53,000
|
| 83 |
+
If you go down, you can see something called view.
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:53,000 --> 00:00:55,000
|
| 87 |
+
And if you expand this, you will get the name,
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:55,000 --> 00:00:58,000
|
| 91 |
+
which is Internal Resource View Resolver, which is this.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:58,000 --> 00:01:02,000
|
| 95 |
+
I will copy this name, qualified copy, qualified name.
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:01:02,000 --> 00:01:05,000
|
| 99 |
+
And in this you have to mention the class equal to
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:01:05,000 --> 00:01:08,000
|
| 103 |
+
and in the double codes, just mention
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:01:08,000 --> 00:01:10,000
|
| 107 |
+
that without the class extension.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:10,000 --> 00:01:11,000
|
| 111 |
+
That's it.
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:11,000 --> 00:01:12,000
|
| 115 |
+
This is how you mention that.
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:12,000 --> 00:01:15,000
|
| 119 |
+
I'm going to configure the internal view resolver,
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:15,000 --> 00:01:17,000
|
| 123 |
+
but you have to set two properties.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:17,000 --> 00:01:20,000
|
| 127 |
+
The first is prefix and the second is suffix.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:20,000 --> 00:01:23,000
|
| 131 |
+
So properties, and again we have used the same thing.
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:23,000 --> 00:01:27,000
|
| 135 |
+
If you remember prefix suffix, let's set that.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:27,000 --> 00:01:29,000
|
| 139 |
+
So property is prefix.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:29,000 --> 00:01:31,000
|
| 143 |
+
The value is slash views slash
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:31,000 --> 00:01:33,000
|
| 147 |
+
because that's a folder I think.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:33,000 --> 00:01:36,000
|
| 151 |
+
Let's see, yeah, the folder name is views.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:36,000 --> 00:01:40,000
|
| 155 |
+
And next we have to mention the property,
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:40,000 --> 00:01:43,000
|
| 159 |
+
which is the suffix, which is in this case is .gsp.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:43,000 --> 00:01:44,000
|
| 163 |
+
That's it.
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:44,000 --> 00:01:47,000
|
| 167 |
+
That's how basically you configure things
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:47,000 --> 00:01:49,000
|
| 171 |
+
and now you know the importance of Spring Boot, right?
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:49,000 --> 00:01:52,000
|
| 175 |
+
How easy it is to do everything in Spring Boot.
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:52,000 --> 00:01:56,000
|
| 179 |
+
So now after making the changes, let's reload
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:56,000 --> 00:01:58,000
|
| 183 |
+
or relaunch the application.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:58,000 --> 00:02:01,000
|
| 187 |
+
Let's go back and refresh.
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:02:01,000 --> 00:02:03,000
|
| 191 |
+
Oh, and this time we got a different error.
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:02:03,000 --> 00:02:04,000
|
| 195 |
+
Good thing, right?
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:02:04,000 --> 00:02:05,000
|
| 199 |
+
Every time we do something you get
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:02:05,000 --> 00:02:07,000
|
| 203 |
+
different error, but it looks like I made a mistake.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:02:07,000 --> 00:02:10,000
|
| 207 |
+
Line number 20. Let's see, line number 20.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:02:10,000 --> 00:02:14,000
|
| 211 |
+
It says perfect property things are looking good.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:02:14,000 --> 00:02:17,000
|
| 215 |
+
What is wrong there? Oh, this is not how you do it.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:02:17,000 --> 00:02:19,000
|
| 219 |
+
I still went into a different way.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:19,000 --> 00:02:20,000
|
| 223 |
+
So I have to set the value.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:20,000 --> 00:02:22,000
|
| 227 |
+
Remember in Spring Boot we have talked about the values.
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:22,000 --> 00:02:25,000
|
| 231 |
+
I will say slash views slash,
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:25,000 --> 00:02:27,000
|
| 235 |
+
and this should be also value.jsp.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:27,000 --> 00:02:30,000
|
| 239 |
+
Sometime you just go with the intuitions, right?
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:30,000 --> 00:02:32,000
|
| 243 |
+
And then it doesn't work. Anyway.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:32,000 --> 00:02:35,000
|
| 247 |
+
So you have to set the values like this, not in the bracket.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:35,000 --> 00:02:39,000
|
| 251 |
+
Let's relaunch and go back here, relaunch the application
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:39,000 --> 00:02:41,000
|
| 255 |
+
and voila, we got our page.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:41,000 --> 00:02:43,000
|
| 259 |
+
So this is working, but let's see
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:43,000 --> 00:02:45,000
|
| 263 |
+
if the actual output also works.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:45,000 --> 00:02:48,000
|
| 267 |
+
So I will say 121.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:48,000 --> 00:02:51,000
|
| 271 |
+
And here I will say, Navin, enter, submit. And you got it.
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:51,000 --> 00:02:53,000
|
| 275 |
+
You got the output. Not exactly,
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:53,000 --> 00:02:55,000
|
| 279 |
+
I mean we have not seen this problem before,
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:55,000 --> 00:02:57,000
|
| 283 |
+
but you can see we are not getting the value.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:57,000 --> 00:02:59,000
|
| 287 |
+
We wanted the value, which is data
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:59,000 --> 00:03:01,000
|
| 291 |
+
and we wanted it to print.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:03:01,000 --> 00:03:03,000
|
| 295 |
+
Welcome to the Java world. What is not working?
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:03:03,000 --> 00:03:06,000
|
| 299 |
+
Let's go back to our code.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:03:06,000 --> 00:03:08,000
|
| 303 |
+
And if you go to the home controller,
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:03:08,000 --> 00:03:12,000
|
| 307 |
+
if you can see we do have this alien object here
|
| 308 |
+
|
| 309 |
+
78
|
| 310 |
+
00:03:13,000 --> 00:03:15,000
|
| 311 |
+
and we are returning the result page.
|
| 312 |
+
|
| 313 |
+
79
|
| 314 |
+
00:03:15,000 --> 00:03:17,000
|
| 315 |
+
And we do have the course model attribute,
|
| 316 |
+
|
| 317 |
+
80
|
| 318 |
+
00:03:17,000 --> 00:03:18,000
|
| 319 |
+
which returns Java.
|
| 320 |
+
|
| 321 |
+
81
|
| 322 |
+
00:03:18,000 --> 00:03:20,000
|
| 323 |
+
So it should work, right? See, sometime
|
| 324 |
+
|
| 325 |
+
82
|
| 326 |
+
00:03:20,000 --> 00:03:23,000
|
| 327 |
+
what happens is in your JSP because of some,
|
| 328 |
+
|
| 329 |
+
83
|
| 330 |
+
00:03:25,000 --> 00:03:27,000
|
| 331 |
+
because of some support, JSTL might not work.
|
| 332 |
+
|
| 333 |
+
84
|
| 334 |
+
00:03:27,000 --> 00:03:29,000
|
| 335 |
+
So if you go back to result page, you have
|
| 336 |
+
|
| 337 |
+
85
|
| 338 |
+
00:03:29,000 --> 00:03:33,000
|
| 339 |
+
to add one more attribute here, which is isELIgnored.
|
| 340 |
+
|
| 341 |
+
86
|
| 342 |
+
00:03:33,000 --> 00:03:35,000
|
| 343 |
+
So you have to make sure this is always false
|
| 344 |
+
|
| 345 |
+
87
|
| 346 |
+
00:03:35,000 --> 00:03:37,000
|
| 347 |
+
and you have to put that in double quotes.
|
| 348 |
+
|
| 349 |
+
88
|
| 350 |
+
00:03:37,000 --> 00:03:39,000
|
| 351 |
+
So sometime the expression language,
|
| 352 |
+
|
| 353 |
+
89
|
| 354 |
+
00:03:39,000 --> 00:03:41,000
|
| 355 |
+
so this is called the expression language
|
| 356 |
+
|
| 357 |
+
90
|
| 358 |
+
00:03:41,000 --> 00:03:43,000
|
| 359 |
+
and sometime your framework ignores it.
|
| 360 |
+
|
| 361 |
+
91
|
| 362 |
+
00:03:43,000 --> 00:03:46,000
|
| 363 |
+
So you have to make sure that you say, Hey, don't ignore it,
|
| 364 |
+
|
| 365 |
+
92
|
| 366 |
+
00:03:46,000 --> 00:03:48,000
|
| 367 |
+
convert this value and let's see if this works.
|
| 368 |
+
|
| 369 |
+
93
|
| 370 |
+
00:03:48,000 --> 00:03:53,000
|
| 371 |
+
Let's go back to the output page refresh. And it worked.
|
| 372 |
+
|
| 373 |
+
94
|
| 374 |
+
00:03:53,000 --> 00:03:55,000
|
| 375 |
+
So that's how basically it works.
|
| 376 |
+
|
| 377 |
+
95
|
| 378 |
+
00:03:55,000 --> 00:03:58,000
|
| 379 |
+
And we were able to convert our project,
|
| 380 |
+
|
| 381 |
+
96
|
| 382 |
+
00:03:58,000 --> 00:04:01,000
|
| 383 |
+
the entire project from Spring Boot
|
| 384 |
+
|
| 385 |
+
97
|
| 386 |
+
00:04:01,000 --> 00:04:03,000
|
| 387 |
+
to normal spring MVC without using Spring Boot of course.
|
| 388 |
+
|
| 389 |
+
98
|
| 390 |
+
00:04:03,000 --> 00:04:08,000
|
| 391 |
+
And we have done a lot of configuration.
|
| 392 |
+
|
| 393 |
+
99
|
| 394 |
+
00:04:08,000 --> 00:04:10,000
|
| 395 |
+
So let's do a quick recap in the next video.
|
| 396 |
+
|
| 397 |
+
100
|
| 398 |
+
00:04:10,000 --> 00:04:11,000
|
| 399 |
+
Whatever we have done, step by step so
|
| 400 |
+
|
| 401 |
+
101
|
| 402 |
+
00:04:11,000 --> 00:04:13,000
|
| 403 |
+
that you will remember what to do when you want
|
| 404 |
+
|
| 405 |
+
102
|
| 406 |
+
00:04:13,000 --> 00:04:15,000
|
| 407 |
+
to build a Spring MBC application.
|
| 408 |
+
|
13 - Exploring Web MVC without Spring Boot/006 Source-Code.url
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[InternetShortcut]
|
| 2 |
+
URL=https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.6%20Internal%20Resource%20View%20Resolver
|
13 - Exploring Web MVC without Spring Boot/007 Summary_en.srt
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(gentle music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:05,000
|
| 7 |
+
-: So let's do a quick recap of this app.
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:05,000 --> 00:00:07,000
|
| 11 |
+
So what we have done is,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:08,000
|
| 15 |
+
initially when you build this project,
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:08,000 --> 00:00:10,000
|
| 19 |
+
you will get a Maven project.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:10,000 --> 00:00:12,000
|
| 23 |
+
You have to make sure that you add
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:12,000 --> 00:00:14,000
|
| 27 |
+
this dependency for SpringMVC.
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:14,000 --> 00:00:17,000
|
| 31 |
+
Now this is SpringMVC, not Spring Boot,
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:17,000 --> 00:00:19,000
|
| 35 |
+
and the version I'm going for is 6.1.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:19,000 --> 00:00:20,000
|
| 39 |
+
Now. depending upon when you're watching this,
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:20,000 --> 00:00:22,000
|
| 43 |
+
you can try out your own version.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:22,000 --> 00:00:26,000
|
| 47 |
+
And once we do this, we can create our controller.
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:26,000 --> 00:00:28,000
|
| 51 |
+
So if you can see, I am creating a home controller here
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:28,000 --> 00:00:30,000
|
| 55 |
+
in which I have different methods.
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:30,000 --> 00:00:32,000
|
| 59 |
+
Of course, we are using annotations here for the mapping.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:32,000 --> 00:00:34,000
|
| 63 |
+
But then to make this work,
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:34,000 --> 00:00:37,000
|
| 67 |
+
we have to make sure that you ask your Tomcat,
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:37,000 --> 00:00:40,000
|
| 71 |
+
because Tomcat by default have no idea
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:40,000 --> 00:00:43,000
|
| 75 |
+
that you are using a Spring project or SpringMVC project.
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:43,000 --> 00:00:45,000
|
| 79 |
+
So you have to tell, "Hey, you know,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:45,000 --> 00:00:47,000
|
| 83 |
+
I want to use SpringMVC here."
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:47,000 --> 00:00:49,000
|
| 87 |
+
And the first controller
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:49,000 --> 00:00:51,000
|
| 91 |
+
or the first servlet you have to interact with
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:51,000 --> 00:00:53,000
|
| 95 |
+
is a DispatcherServlet
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:53,000 --> 00:00:55,000
|
| 99 |
+
which is given by the Spring Framework.
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:55,000 --> 00:00:59,000
|
| 103 |
+
For all the requests, you have to call a DispatcherServlet.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:59,000 --> 00:01:02,000
|
| 107 |
+
That's what we are doing in the web.xml file.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:01:02,000 --> 00:01:04,000
|
| 111 |
+
Now, whom we are talking to using web.xml?
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:04,000 --> 00:01:05,000
|
| 115 |
+
We are talking to Tomcat, okay?
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:05,000 --> 00:01:08,000
|
| 119 |
+
So every file here is responsible for talking to something.
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:08,000 --> 00:01:11,000
|
| 123 |
+
So web.xml is a way to talk to Tomcat.
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:11,000 --> 00:01:14,000
|
| 127 |
+
And then when you call DispatcherServlet,
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:14,000 --> 00:01:15,000
|
| 131 |
+
now DispatcherServlet has no idea
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:15,000 --> 00:01:16,000
|
| 135 |
+
that you're using a controller.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:16,000 --> 00:01:18,000
|
| 139 |
+
Now, we have to talk to DispatcherServlet.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:18,000 --> 00:01:21,000
|
| 143 |
+
And the way you do that is using the DispatcherServlet name,
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:21,000 --> 00:01:24,000
|
| 147 |
+
which is TELUSKO in this case, -servlet.xml.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:24,000 --> 00:01:27,000
|
| 151 |
+
This is our file which will be there in the WEB-INF folder.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:27,000 --> 00:01:31,000
|
| 155 |
+
In this, you have to mention that I am using annotations
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:31,000 --> 00:01:32,000
|
| 159 |
+
using annotation-config.
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:32,000 --> 00:01:34,000
|
| 163 |
+
And the package you will find all these classes
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:34,000 --> 00:01:36,000
|
| 167 |
+
is com.telusko.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:36,000 --> 00:01:38,000
|
| 171 |
+
And then this basically knows that, hey,
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:38,000 --> 00:01:40,000
|
| 175 |
+
I have to look at this controller,
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:40,000 --> 00:01:42,000
|
| 179 |
+
I have to map it,
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:42,000 --> 00:01:44,000
|
| 183 |
+
and then I have to call a particular page.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:44,000 --> 00:01:46,000
|
| 187 |
+
So like I'm calling the home method here,
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:46,000 --> 00:01:48,000
|
| 191 |
+
which is calling "index".
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:48,000 --> 00:01:50,000
|
| 195 |
+
So DispatcherServlet has no idea what "index" is.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:50,000 --> 00:01:52,000
|
| 199 |
+
So I have to mention the location of Index
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:52,000 --> 00:01:53,000
|
| 203 |
+
and the extension.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:53,000 --> 00:01:55,000
|
| 207 |
+
The way you can do that
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:55,000 --> 00:01:57,000
|
| 211 |
+
is with the help of Internal View Resolver,
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:57,000 --> 00:01:59,000
|
| 215 |
+
which we have configured here.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:01:59,000 --> 00:02:01,000
|
| 219 |
+
So Internal Resource View Resolver.
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:02:01,000 --> 00:02:02,000
|
| 223 |
+
In which you have to mention the prefix,
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:02:02,000 --> 00:02:04,000
|
| 227 |
+
that means the location of the file,
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:02:04,000 --> 00:02:06,000
|
| 231 |
+
and the extension for the file, which is suffix,
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:02:06,000 --> 00:02:08,000
|
| 235 |
+
and that is your .jsp.
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:02:08,000 --> 00:02:11,000
|
| 239 |
+
And that's how the entire project is working.
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:11,000 --> 00:02:13,000
|
| 243 |
+
So again, you have to do this configuration,
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:13,000 --> 00:02:15,000
|
| 247 |
+
but remember, for a big project,
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:15,000 --> 00:02:17,000
|
| 251 |
+
you will do this configuration only once.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:17,000 --> 00:02:20,000
|
| 255 |
+
As you add more features, you have to do more configuration.
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:20,000 --> 00:02:21,000
|
| 259 |
+
But again, remember,
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:21,000 --> 00:02:22,000
|
| 263 |
+
you will do this configuration only once
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:22,000 --> 00:02:24,000
|
| 267 |
+
for the entire project.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:24,000 --> 00:02:26,000
|
| 271 |
+
So is it worth building project in SpringMVC?
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:26,000 --> 00:02:28,000
|
| 275 |
+
Yes, you get more controls.
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:28,000 --> 00:02:30,000
|
| 279 |
+
And is it worth building project in Spring Boot?
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:30,000 --> 00:02:31,000
|
| 283 |
+
Yes, if it will save your time.
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:31,000 --> 00:02:34,000
|
| 287 |
+
So it depends upon what kind of project you're building.
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:34,000 --> 00:02:37,000
|
| 291 |
+
I have seen projects also built in normal SpringMVC,
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:37,000 --> 00:02:38,000
|
| 295 |
+
without Spring Boot.
|
| 296 |
+
|
| 297 |
+
75
|
| 298 |
+
00:02:38,000 --> 00:02:40,000
|
| 299 |
+
But most of the projects are using Spring Boot.
|
| 300 |
+
|
| 301 |
+
76
|
| 302 |
+
00:02:40,000 --> 00:02:44,000
|
| 303 |
+
So after this, we'll add some more features into Spring,
|
| 304 |
+
|
| 305 |
+
77
|
| 306 |
+
00:02:44,000 --> 00:02:46,000
|
| 307 |
+
but with the help of Spring Boot.
|
| 308 |
+
|
13 - Exploring Web MVC without Spring Boot/external-links.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
002 Source-Code
|
| 3 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.2%20Creating%20a%20Spring%20MVC%20Project_1
|
| 4 |
+
|
| 5 |
+
003 Source-Code
|
| 6 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.3%20Running%20Tomcat%20in%20Eclipse
|
| 7 |
+
|
| 8 |
+
004 Source-Code
|
| 9 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.4%20Dispatcher%20Servlet
|
| 10 |
+
|
| 11 |
+
005 Source-Code
|
| 12 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.5%20Configuring%20the%20DispatcherServlet
|
| 13 |
+
|
| 14 |
+
006 Source-Code
|
| 15 |
+
https://github.com/navinreddy20/spring6-course/tree/f1161e151ea06b68810b3cae03005d4955a96a8b/7%20Exploring%20Web%20MVC%20without%20Spring%20Boot/6.6%20Internal%20Resource%20View%20Resolver
|
14 - Building a Project/001 Building Job App_en.srt
ADDED
|
@@ -0,0 +1,296 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
1
|
| 2 |
+
00:00:00,000 --> 00:00:03,000
|
| 3 |
+
(bright music)
|
| 4 |
+
|
| 5 |
+
2
|
| 6 |
+
00:00:03,000 --> 00:00:04,000
|
| 7 |
+
-: With whatever we have learned 'til now,
|
| 8 |
+
|
| 9 |
+
3
|
| 10 |
+
00:00:04,000 --> 00:00:07,000
|
| 11 |
+
basically we have talked about Spring, Spring Boot,
|
| 12 |
+
|
| 13 |
+
4
|
| 14 |
+
00:00:07,000 --> 00:00:09,000
|
| 15 |
+
and we also know how do you build a web application
|
| 16 |
+
|
| 17 |
+
5
|
| 18 |
+
00:00:09,000 --> 00:00:10,000
|
| 19 |
+
with the help of Spring framework.
|
| 20 |
+
|
| 21 |
+
6
|
| 22 |
+
00:00:10,000 --> 00:00:12,000
|
| 23 |
+
Now, when you talk about web application
|
| 24 |
+
|
| 25 |
+
7
|
| 26 |
+
00:00:12,000 --> 00:00:15,000
|
| 27 |
+
and if you try to build a view
|
| 28 |
+
|
| 29 |
+
8
|
| 30 |
+
00:00:15,000 --> 00:00:16,000
|
| 31 |
+
inside your Spring project as well,
|
| 32 |
+
|
| 33 |
+
9
|
| 34 |
+
00:00:16,000 --> 00:00:18,000
|
| 35 |
+
we can do that with the help of JSP.
|
| 36 |
+
|
| 37 |
+
10
|
| 38 |
+
00:00:18,000 --> 00:00:20,000
|
| 39 |
+
And that's what we have done 'til now, right?
|
| 40 |
+
|
| 41 |
+
11
|
| 42 |
+
00:00:20,000 --> 00:00:22,000
|
| 43 |
+
Now on that, let's build an application.
|
| 44 |
+
|
| 45 |
+
12
|
| 46 |
+
00:00:22,000 --> 00:00:25,000
|
| 47 |
+
Now what we are building, we are building a job application,
|
| 48 |
+
|
| 49 |
+
13
|
| 50 |
+
00:00:25,000 --> 00:00:27,000
|
| 51 |
+
or you can say a job portal,
|
| 52 |
+
|
| 53 |
+
14
|
| 54 |
+
00:00:27,000 --> 00:00:29,000
|
| 55 |
+
where people can, or companies can post
|
| 56 |
+
|
| 57 |
+
15
|
| 58 |
+
00:00:29,000 --> 00:00:31,000
|
| 59 |
+
about a particular job.
|
| 60 |
+
|
| 61 |
+
16
|
| 62 |
+
00:00:31,000 --> 00:00:35,000
|
| 63 |
+
And then as a job seeker, you can search for a job.
|
| 64 |
+
|
| 65 |
+
17
|
| 66 |
+
00:00:35,000 --> 00:00:37,000
|
| 67 |
+
So this is what we are building here.
|
| 68 |
+
|
| 69 |
+
18
|
| 70 |
+
00:00:37,000 --> 00:00:38,000
|
| 71 |
+
So let's say if you are searching for a job
|
| 72 |
+
|
| 73 |
+
19
|
| 74 |
+
00:00:38,000 --> 00:00:40,000
|
| 75 |
+
and then you want to see
|
| 76 |
+
|
| 77 |
+
20
|
| 78 |
+
00:00:40,000 --> 00:00:41,000
|
| 79 |
+
what are the different jobs available,
|
| 80 |
+
|
| 81 |
+
21
|
| 82 |
+
00:00:41,000 --> 00:00:43,000
|
| 83 |
+
or the the requirements,
|
| 84 |
+
|
| 85 |
+
22
|
| 86 |
+
00:00:43,000 --> 00:00:45,000
|
| 87 |
+
you can simply click on View All Jobs here.
|
| 88 |
+
|
| 89 |
+
23
|
| 90 |
+
00:00:45,000 --> 00:00:48,000
|
| 91 |
+
And this will list the number of jobs available.
|
| 92 |
+
|
| 93 |
+
24
|
| 94 |
+
00:00:48,000 --> 00:00:51,000
|
| 95 |
+
You can see they're looking for Java developers
|
| 96 |
+
|
| 97 |
+
25
|
| 98 |
+
00:00:51,000 --> 00:00:53,000
|
| 99 |
+
with the experience in core Java, advanced Java,
|
| 100 |
+
|
| 101 |
+
26
|
| 102 |
+
00:00:53,000 --> 00:00:56,000
|
| 103 |
+
experience two years, and then the tech stack.
|
| 104 |
+
|
| 105 |
+
27
|
| 106 |
+
00:00:56,000 --> 00:00:58,000
|
| 107 |
+
Then we have front developer, three years.
|
| 108 |
+
|
| 109 |
+
28
|
| 110 |
+
00:00:58,000 --> 00:01:02,000
|
| 111 |
+
Now all these are just data which we randomly inserted,
|
| 112 |
+
|
| 113 |
+
29
|
| 114 |
+
00:01:02,000 --> 00:01:03,000
|
| 115 |
+
but it doesn't matter, right?
|
| 116 |
+
|
| 117 |
+
30
|
| 118 |
+
00:01:03,000 --> 00:01:04,000
|
| 119 |
+
We got this data here,
|
| 120 |
+
|
| 121 |
+
31
|
| 122 |
+
00:01:04,000 --> 00:01:07,000
|
| 123 |
+
and now if you want to apply for a job,
|
| 124 |
+
|
| 125 |
+
32
|
| 126 |
+
00:01:07,000 --> 00:01:08,000
|
| 127 |
+
you can see a particular thing.
|
| 128 |
+
|
| 129 |
+
33
|
| 130 |
+
00:01:08,000 --> 00:01:09,000
|
| 131 |
+
And of course there should be a button here
|
| 132 |
+
|
| 133 |
+
34
|
| 134 |
+
00:01:09,000 --> 00:01:10,000
|
| 135 |
+
for applying a job.
|
| 136 |
+
|
| 137 |
+
35
|
| 138 |
+
00:01:10,000 --> 00:01:12,000
|
| 139 |
+
And also there should be a company name.
|
| 140 |
+
|
| 141 |
+
36
|
| 142 |
+
00:01:12,000 --> 00:01:13,000
|
| 143 |
+
But just to keep it simple,
|
| 144 |
+
|
| 145 |
+
37
|
| 146 |
+
00:01:13,000 --> 00:01:15,000
|
| 147 |
+
we went for these different profiles here.
|
| 148 |
+
|
| 149 |
+
38
|
| 150 |
+
00:01:15,000 --> 00:01:16,000
|
| 151 |
+
That's one.
|
| 152 |
+
|
| 153 |
+
39
|
| 154 |
+
00:01:16,000 --> 00:01:20,000
|
| 155 |
+
Next, what if you are an employer,
|
| 156 |
+
|
| 157 |
+
40
|
| 158 |
+
00:01:20,000 --> 00:01:21,000
|
| 159 |
+
and you want to post about a job?
|
| 160 |
+
|
| 161 |
+
41
|
| 162 |
+
00:01:21,000 --> 00:01:22,000
|
| 163 |
+
So you can click on this Add Job
|
| 164 |
+
|
| 165 |
+
42
|
| 166 |
+
00:01:22,000 --> 00:01:24,000
|
| 167 |
+
and you can post a requirement.
|
| 168 |
+
|
| 169 |
+
43
|
| 170 |
+
00:01:24,000 --> 00:01:26,000
|
| 171 |
+
Of course this should be auto-generated,
|
| 172 |
+
|
| 173 |
+
44
|
| 174 |
+
00:01:26,000 --> 00:01:27,000
|
| 175 |
+
but at this point,
|
| 176 |
+
|
| 177 |
+
45
|
| 178 |
+
00:01:27,000 --> 00:01:29,000
|
| 179 |
+
let's say we have some hardware values there,
|
| 180 |
+
|
| 181 |
+
46
|
| 182 |
+
00:01:29,000 --> 00:01:30,000
|
| 183 |
+
and then we have a post profile.
|
| 184 |
+
|
| 185 |
+
47
|
| 186 |
+
00:01:30,000 --> 00:01:35,000
|
| 187 |
+
Let's say we are looking for a Spring dev
|
| 188 |
+
|
| 189 |
+
48
|
| 190 |
+
00:01:35,000 --> 00:01:36,000
|
| 191 |
+
and some requirement,
|
| 192 |
+
|
| 193 |
+
49
|
| 194 |
+
00:01:36,000 --> 00:01:38,000
|
| 195 |
+
let's say experience of one year in Spring.
|
| 196 |
+
|
| 197 |
+
50
|
| 198 |
+
00:01:38,000 --> 00:01:42,000
|
| 199 |
+
And I want the person to know Java,
|
| 200 |
+
|
| 201 |
+
51
|
| 202 |
+
00:01:42,000 --> 00:01:44,000
|
| 203 |
+
and there should be Spring as well here.
|
| 204 |
+
|
| 205 |
+
52
|
| 206 |
+
00:01:44,000 --> 00:01:45,000
|
| 207 |
+
And I'm not able to find.
|
| 208 |
+
|
| 209 |
+
53
|
| 210 |
+
00:01:45,000 --> 00:01:47,000
|
| 211 |
+
Let's say I want someone who knows Java and TypeScript.
|
| 212 |
+
|
| 213 |
+
54
|
| 214 |
+
00:01:47,000 --> 00:01:49,000
|
| 215 |
+
I will click on Submit and we got an error.
|
| 216 |
+
|
| 217 |
+
55
|
| 218 |
+
00:01:49,000 --> 00:01:52,000
|
| 219 |
+
Not expected, but it should bring something, right?
|
| 220 |
+
|
| 221 |
+
56
|
| 222 |
+
00:01:52,000 --> 00:01:54,000
|
| 223 |
+
So there's something wrong with the code.
|
| 224 |
+
|
| 225 |
+
57
|
| 226 |
+
00:01:54,000 --> 00:01:55,000
|
| 227 |
+
Again, we'll figure it out, and we'll make it work,
|
| 228 |
+
|
| 229 |
+
58
|
| 230 |
+
00:01:55,000 --> 00:01:57,000
|
| 231 |
+
but it should add the job.
|
| 232 |
+
|
| 233 |
+
59
|
| 234 |
+
00:01:57,000 --> 00:01:59,000
|
| 235 |
+
And when you go back to View All Jobs,
|
| 236 |
+
|
| 237 |
+
60
|
| 238 |
+
00:01:59,000 --> 00:02:00,000
|
| 239 |
+
of course it should be there, right?
|
| 240 |
+
|
| 241 |
+
61
|
| 242 |
+
00:02:00,000 --> 00:02:02,000
|
| 243 |
+
This is what we want to build now.
|
| 244 |
+
|
| 245 |
+
62
|
| 246 |
+
00:02:02,000 --> 00:02:04,000
|
| 247 |
+
It's not complete, and that's why we got the error.
|
| 248 |
+
|
| 249 |
+
63
|
| 250 |
+
00:02:04,000 --> 00:02:05,000
|
| 251 |
+
But let's build this.
|
| 252 |
+
|
| 253 |
+
64
|
| 254 |
+
00:02:05,000 --> 00:02:07,000
|
| 255 |
+
Now, how we are going to start this?
|
| 256 |
+
|
| 257 |
+
65
|
| 258 |
+
00:02:07,000 --> 00:02:09,000
|
| 259 |
+
Of course, we don't want to focus on the views here
|
| 260 |
+
|
| 261 |
+
66
|
| 262 |
+
00:02:09,000 --> 00:02:11,000
|
| 263 |
+
because there are a lot of CSS involved here.
|
| 264 |
+
|
| 265 |
+
67
|
| 266 |
+
00:02:11,000 --> 00:02:13,000
|
| 267 |
+
So I have the view theories.
|
| 268 |
+
|
| 269 |
+
68
|
| 270 |
+
00:02:13,000 --> 00:02:15,000
|
| 271 |
+
We want to build the backend, okay?
|
| 272 |
+
|
| 273 |
+
69
|
| 274 |
+
00:02:15,000 --> 00:02:17,000
|
| 275 |
+
So in the next video I will show you
|
| 276 |
+
|
| 277 |
+
70
|
| 278 |
+
00:02:17,000 --> 00:02:19,000
|
| 279 |
+
how we have built that view.
|
| 280 |
+
|
| 281 |
+
71
|
| 282 |
+
00:02:19,000 --> 00:02:20,000
|
| 283 |
+
In fact, we'll create the project first,
|
| 284 |
+
|
| 285 |
+
72
|
| 286 |
+
00:02:20,000 --> 00:02:23,000
|
| 287 |
+
and then we'll add some views which I've already created,
|
| 288 |
+
|
| 289 |
+
73
|
| 290 |
+
00:02:23,000 --> 00:02:25,000
|
| 291 |
+
and we'll see how those views looks like.
|
| 292 |
+
|
| 293 |
+
74
|
| 294 |
+
00:02:25,000 --> 00:02:28,000
|
| 295 |
+
And then we'll start coding the Java part of it.
|
| 296 |
+
|