Model View Controller: Spring MVC - Full-stack tech walkthrough || Model || Data Flow

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so it's right now 11 o'clock in the evening I mean it's 11 o'clock in the night so right now we're here to discuss a very important topic called murder it is very important topic I said but this is a very simple topic right because if you know how to create objects in Java then you know murder okay so what do you mean by modern okay so model means data right and from where we can get data we can get data from the database we also can get data from users right I can give you your form registration form right I'll tell you to enter your first name last name email phone number city everything then you click Submit I gather all your data right once I get all this data right how can I transfer those data from one layer to one layer obviously by creating a object and setting all those data with my object properties okay don't go into that we will be understanding it in the simplest way possible so today we will be covering model model in spring MVC obviously we already understood front controller controller and view so the UN controller we have already understood only one thing is pending which is called model and as I said it's pretty simple to understand and today I'm going to do I'm going to create a very simple website it's not a website but for learning purpose I can say it's a website so right now I think I'm sharing my screen here right now we're going to create something like this today okay so whenever I am going to load my project in my server and I do enter I'm going to see something just like this welcome to home comm then there will be a link and the link you can see link to mom's cafe okay think like I'm staying in my home and obviously whenever I need a coffee I need a tea or I need some food to have I say right mom could you please to do this for me mom could you please bring that for me think like if my mom is really digitalized right he'll nurse apes I do not accept order like this rather it can give me an order by visiting my website so you can visit to my mom's website or anybody's mom's website by clicking here link to Mom's cafe and once you click that link you should arrive in this particular page and you can put in your item name over here let's say I want a masala tea okay and I will click this particular button called order once I click that and I'll get myself order received your order masala tea is getting processed so it's a pretty simple website but this website right now will help us to do some hands-on we'll be getting into the real time code right now we'll get our hands dirty we'll be working with model-view-controller we'll be seeing a lot of diagrams and obviously we'll do a lot of hands-on today okay let's get started what to wait for okay so I have shown you a demo website that we are going to create in this particular video but before we get into that it's really important to understand about the model because this is the only one thing that we are missing as of now right because we already have a good knowledge on controller front controller and view model let's learn about it right now then we can move into that okay so first thing is you know what I'm going to create a new controller so let me go to Java resources here and let me go to SRC comes controller basically I am going to create a new package right now I'm done with this controllers I'm going to create a new package they say come to at home dot let's say my cafe controllers my cafe dot controllers okay let me hit finish and here in this package I'm going to create a new class called my Caffe controllers cool I'm going to hit finish basically here I have created in your controllers okay so the first thing that I'm going to do here in this controller I'm going to annotate this particular class is a annotation called add controller okay so basically I'm telling my spring right now this particular class is a controller and whenever spring will do a component scan this particular controller will be registered with my container right with my spring container so to make it happen I had to go to my bin store XML file and there here is my base package right this is my context components can so basically spring is going to scan this particular package which is this one and spring is going to register these three controllers okay with my you know spring web application context or with my container right but I also want spring to scan the classes which is available inside this particular package which is just I have created right so I'm going to this particular class right now actually I'm going to copy my package name from here I I'll do a control say and I'll go to my bin start XML file here and here I'm going to put a comma and I'll do a control P so now my spring is going to scan this particular package and this package as well so my new controller which is this one is also going to be register with the spring container that's what I want okay so the next thing is right now I'm going to create a handler method which is going to return a view okay basically this this view I'm going to create it for my cafe the name of my cafe is going to be mom's café as I said you so what I'm going to do here I'm going to create a public method public and string a say show welcome page welcome page and this particular handler method job is it is going to return a welcome face welcome it's a underscore it's a dash page okay there you go and let's have a request mapping attached with this particular method and let me say the request mapping for this is going to be this is last cafe okay so whenever I'm going to say home comm slash cafe this particular method will be invoked and this particular page will be written so let me copy this space name and I'm going to create a new view right now with this particular page name so I'm going to go to my view folder that I've created in the last video probably and I'm going to create a new view called let me create a JSP file right now and let me say welcome page dot JSP okay next finish okay it's basically going to create mini in our dummy CSV file and last time to make you understand something here I changed this particular previous view that I have created here the extension I've changed it to dot HTML let me rename it and let me say it dot JSP right now because you will be using just before our view okay I will also go to my pins dot XML file my spring configuration file where I have actually created my view result for last time here I'll change the extension from dot HTML to dot JSP because I'm going to use JSP for my view right now so you can see right now I don't need to go to my controller to change the view extension I can come to my spring configuration file right here and I can change this particular value to dot HTML to touch SP if day after tomorrow I'm going to use velocity or free marker or timely I can change my extension just coming right over here to the X to the spring configuration file and from here only I can change their you know whatever the technology that I'm planning to use okay pretty simple cool so right now let me go to my welcome page where is my welcome page yeah here we go this one so here let me just give me a one tag right now and let me say what is that scatter right my website name is going to be mom's café school and obviously I'm going to align this h1 tag to center right and I'm going to give a HR here right there you go okay so basically I have created a controller right now which is going to which is going to return a page called welcome page and this particular page actually I have created right over here in my view cool so right now we are ready to test this application so let me do a right-click here let me do run is where is that run is run and serve go okay let me do hit the next button here and let me do finish and let me wait my server to start come on man do it faster okay there you go so right now I can write here what is that home dot sorry home comms class cafe and there we go mom's café cool so right now you understand about controller you understand about view now let's bring in model so unless they from from my control okay let's say here this is my controller right that's it from my controller I want to send some data to the view cool data can be calm from anywhere right I can just get it from the database I can get it from a user I can get it from a file I can get it from a collection I can get it from anywhere right for now over here just to make you understand I'm going to you know I'm going to use some hard-coded value here but my goal is over here to same data from controller to view but my goal here is to understand the flow the way the data is getting processed in a spring MVC application once I understand that then things are pretty easy okay so first of all right here this particular page right now in this particular controller right now I'm going to send some data to my view okay so let's say I can comment something here sending data to the you okay or you can say sending data to view I can Marcus smart something here inside the bracket called JSP page which will be pretty more understandable for beginners I'm sending data to the JSP page from my controller okay so the way that I'm going to do it over here basically I'm going to create a I'm going to clear something let's say what I can create okay so let's say my name okay let's say string my name okay and my name is the lash ok bhi LSS right now let's say I'm going to say in this particular data I'm going to send this particular data or we last which is stored in this my name variable okay I want to send this data to my view and how I'm going to achieve it okay so to send this particular data to my view the way I'm going to you know send this data to my view is by using a object called modal so I'm going to create an object op model so I'll say model where are you model there you go model model I'll say model this is my variable model then what I can do is I can do model dot set set attribute or something not set attribute let's say our attribute okay there you go this one this particular method I'm going to use and I'm going to add this attribute right over here let's say say my name value okay and I'm going to copy this variable name which contains my data and I can put it over here right and there you go you are done so what I did over here whatever this particular variable right now contains the data right I am putting this variable over here who is actually context data okay and here I've just given a name given a dummy name right now this particular thing that I've declared here now this is actually contains my data which is my name and what is my name my name is Aviles simple so what I can do right now that's it that's my job right now I can go to mine welcome pets right this is the page that I've created and to show you everything in one screen I can drag this page to here so this is my mind Kappa controllers this is my welcome page okay so what I'm trying to do over here basically I am trying to send data from my controller to view pace once you add something once you add something in the model object this particular model object this particular thing will be available here in this page right because this particular controller method is returning welcome page here right and before returning this particular page I'm sending some data you know with this particular page as well okay so let me try to access this particular data that I'm sending to my page here right and this particular page is this right now let me access this data right here easy okay nothing to get confused cool so right now let me say something here let's say let me say my name each okay and here let me try to access this particular data okay so what I can say here is a dollar and I can open the curly brace and close the curly brace and here inside this collar brace I will actually use this my name value here okay this one I'll do controls three and I will do control V right here and there you go that's the way you are going to access your data right here in spring and busy cool how easy is that you are getting some error but this is not errors if I am going to close this and if I am going to open this space again what is that welcome page dot ASP there is gone okay so right now you understand how it I can access data so whatever the name I have given here my name value this my name value is actually containing my date I hear my name and this particular my name is a Vilas right so actually I'm using this particular name here right here in my face will come paste at GSP and I'm expecting that right now it is going to show me the value of my name value whatever I had stored there cool so what I can do right now I can read on my project again go to run is run on server and do next let me do finish let me start my server and let me check everything again okay so there you go and here I can do MVC project home comm class cafe okay enter and okay my name is Avinash okay so now it's welcome to your controller you are changing it to something else let's say of a large one two or three okay now this particular thing this particular data I am sending it to my view and right now if I'm going to taste it again so I can go right here and I can refresh the space we can say my name is Abhilash one two three cool simple so right now I'll give you a task now tell me the website heading that I am using mom's café here okay this particular website name actually I'm hard coding let me close this I'm hard coding it over here right in my HTML paste this thing I'm actually hard coding so now if I won this data to come from my controller okay I don't want to hard code it right here okay I want to get this data from my controller then how can I use it could you please guide me doing that I can go to my mom's controller and here another thing I can send here more del dot hard attribute what is that our attribute and here first thing is I can say something lesser like my website header or website title I can say okay and here actually I can give my tell you right I can say mom's café there you go I'll do control s to stab it I'll keep a semicolon and here this particular thing actually contains my data mom's café so I'm going to copy this command C and I'll go to my welcome page and here actually I can keep a dollar sign I can open and close the curly braces and I'll do control V okay now if I'm going to again as I said this is not a error close this open this space again there you go so now what I need to do is I need to start my server so let me click on server icon let me start it from here start and after that if the things are working then now you know how to use model object and how to send data from controller to your view right now my server is started I can go to this browser and I can refresh this okay and you can see moms cafe is actually working right and this data right now this data here right now we are sending it from our controller we are not hard coding it you can say mom dad mom's café 1 2 3 control s you wait to yourself or to reload your changes and once it's done what we can do is we can come here we can refresh this and you can see moms cafe 1 2 3 there you go all right so now that's how easy it is to send data from your controller to your view right okay so right now let's get started with the task that I have shown you during the beginning of this tutorial right okay so basically we're going to create a page just like these that you are seeing on my screen right now we'll have a header right here mom's cafe then we should have a text box which can take any input and it's basically the item name you can see the label right here and here you have to enter some food name let's say I'm entering masala tea and once you click on order then it should navigate me to a different page and it should say or to receive your order something whatever you have entered here okay your order masala tea is getting processed okay so getting spelling is wrong so forgive me for that I'm pretty weak in swelling by the way so now let's get started with the development and let me switch to STS cool so first of all my first job is let me go to my welcome page this is the page that I've developed let me you know remove all this thing this is just to demonstrate to you about the model I do not need my name over here as well and in h1 tag I need moms cafe okay there you go and what I can do here right now I can bring this to one page and I can you know minimizes just so that I can see everything in one screen here let me refresh this particular face okay I'm getting mom's cafe right now and let me do one thing I'm actually going to create a input tag and let me say input type equal to x equal to text and in the name I'm going to give it as food type so basically this text box right here if i refresh the space so this text box right here is going to help us to enter our food order right so I can put a placeholder right here as well placeholder let me say food time okay or I can say what do you want to eat let me say foot type okay if I am going to refresh it you can say for tight let me give a label to this particular text box as well let me say label label and let me say label name is item name okay and let me give a colon here and let me rephrase this okay I'm getting item name here and let me bring this thing to the middle so let me say okay I can do this thing just a sec before that before that if I if I'm using a label like like this if you can see if I'm clicking here right in the item name this is not coming to this particular text box so to link this the correct way to use a label is I can use for attack here and in the for tag I can say let's say item underscore name okay and I can link this label with this input tag right here by putting a ID so I can say ID equal to whatever the name I've given here called item name let me copy this and let me paste it here control V there you go control s so right now if I'm going to refresh the space well there is no changes but if I'm going to click here you can see the link is coming to this particular label there you go okay so the next step is to include a submit button right here so what I can do right now I can come here and I can give some white spaces and I can use a input then type equal to submit there you go and I can say the value equal to order order now I can say cool now if I'm going to refresh it there you go order now and now what I can do is I can I can put all these things inside a div okay I can put deep and deep right here I can cut this tape from here I can put this tails right here control s control a control set F to format everything now let me align this Steve align equal to Center okay so all the element which this diff contains should come to the center there you go and that's what I want we're done with this particular pace cool okay great so now let me drag this paste to here okay okay so my first thing is done right now okay I have designed my welcome page so if you want to can control a control C or URL from here you can go to your web browser you can do control P and if you do a enter you can see the same place your mom's café item name foot type you know you give a foot type let's say masala tea okay and if you do a order now you can see nothing is happening right basically when we click order now here we should redirect the user to a different page and we can we can display him a message your order is received please wait 10 minutes or 20 minutes right right now let me develop a another pace okay which will say order received okay so when that particular page will display that page will be display once you hit the order now icon right and to do that what I can do here I can go to my welcome page again let me drag it to here I can come here and I can put all this thing okay inside a form action so I can do form okay form and let me wrap this form or let me end this form right here okay and now I'll give the action to this let me say process form okay let me our process order let me step process order okay because when you say order now it should you know hit a link called process order okay let me save this let me rephrase this particular page right now okay so right now what I'm expecting from here is that whenever I'm going to hit order now button right here it should redirect to me to a different page called slash process order okay so if I'm going to hit something here let's say some food item I'll enter then I'll hit enter order now right here click and there you can see you are actually redirecting to it print page right now called processed order which is this particular action process order this is the link that you are given this y whenever you are hitting enter you not right now you are in the pace home dot comes last cafe and whenever you do order now you should redirect to a different pace called slash process order okay there we go you and obviously you are getting some Kampala meter here as well food type okay your your input name if you are going to see where is the input here is the input if you are going to see your input right here you can see the name you have given food type here so it is saying put type right here food type and whatever the value we are passing it is saying DF GSI because I have passed that value right here and this particular text box belongs to this particular name hood type so is saying next mr is saying what food type equal to whatever you are entering right the query parameter we say it good so right now the important thing what we understand from here is that whenever we are hitting order now button it is actually firing this particular URL which we need to handle right now then we need to create a new method we need to create a new method in our controller class which is actually going to handle this particular request called process order ok this process order whenever somebody hit the order now button this process order will be fired this particular URL will be fired now I need to handle that URL and I need to return him a page right so let me copy this URL right now control C okay and let me go to my controller class and right here okay I can I can do something right now let me let me save this and let me drag this to here okay let me go to my controllers and here I do not want all these things I have already modified everything my disk controller will only return this controller this particular method job is written the welcome page okay let me stop my server otherwise it will it is going to keep reloading everything okay so let me say the job of this particular method is only to return the welcome page okay so right now let me write it another method here public stream process order process order okay name could be anything but the URL mapping will be important so what is my URL mapping should be for this particular method I can say request mapping here and the value for the request mapping I should go to my welcome page whatever the action that I have given here this particular action will be fired when somebody will enter the order now button and this thing I'm going to handle it right here I'm going to say slash order process order and I can return him a page return something we can return him a page just like process - ordered okay cool so now let me create a new page called process order let me copy this and let me go to view let me do a right-click here let me go to new JSP file and let me say process let me do a control V here dot JSP and let me hit finish now I got my process order pace right and now let me just say your let me say what order received okay and let me give this exclamation mark here and let me put it inside a h1 tag okay let me say h1 tag here control X control be okay and I can say your order is getting processed okay and Dhaka there you go okay right now let me do what let me do read on my project Ronen server and next finish and let me just start my server and let's see whatever we have planned is it working similarly or not or something else is happening so finger crossed hopefully no error so what I'm going to do first I'm going to I didn't go to my web browser right now okay so let me refresh this things are working good okay item name that's the masala I've that space tea order now and there you go order received your order is getting processed now you understand the flow how the flow is going the flow is pretty simple the flow is extremely simple so first whenever you are hitting home dot comes last cafe for this last cafe we have a controller method if you go here this controller method is getting fired right and this controller method is actually returning your paste called welcome pays correct and once this particular method gets involved completely you are seeing the welcome page right here okay this is my welcome page cool and the next thing is whenever you are giving a input and whenever you do order now okay if I'm going to my welcome page right now okay when you do order now whenever you click it when you submit it basically this particular URL is getting fired right processed order right whenever I click order now it is going to the processed order URL right slash process order and therefore this last process order we have written it another controller method you can you can see here this is this is the Matt and this particular method is handlings last process order request and when / process order is getting fired right what is basically happening it is returning this particular pace process order which is this particular phase process or Dodge or JSP which is this one cool easy okay so to do if you are getting confused with that what what is the easiest thing you can do is you can come here right now because I know few beginners confuse with this because whenever there write multiple controller methods that's why I'm going a little slow but be comfortable with this first and after that you can rapidly do your application development with spring MVC so what we can do right now I'll show you another trick if you are getting confused let me stop my server and let me put a debug point here put a debug point here and this try to debug this particular application then check when this particular method is getting called when this particular method is getting caught correct so right now what I can do is I can go to my server where is my server this is my server icon and you can do a right-click instead of start you can send study can hit this debug icon or you can do one thing you can click your right-click debuggers debug on server okay you can do either thing next finish now we can actually hit that PRL we are going to see when this particular method is getting executed and when this particular method is getting executed okay so now my program has started hopefully okay now let me go here let me come to this particular page and let me actually do it enter here now you can see automatically it opens my Eclipse here and it is asking me to switch to the debug tip let me click on switch no problem I can switch to ready now you can see my flow came to which method my flow is actually coming to this particular method right so welcome page because right now it is it is you can see the MyPlate page is reloading right it is trying to show this particular page right so if I am going to hit resume right now my page will be shown you can see my reloading that that that moving icon is stopped right now it did so my welcome pace right so now I can confirm that whenever I'm actually hitting this URL whenever actually I'm doing control X from here I'm opening a new tab I am doing control V and I'm hitting this URL means what see it is keeps moving that means it is trying to invoke my slash Cafe URL so you can see my debug line is here inside my show welcome page right so it is trying to show the Welcome paste so if I hit resume right now you can see here my page is displayed correct so right now if I am going to enter something and if I am going to click order now now which particular method will be executed or the method right if I do order now see where it comes it comes to the processed order method right now this particular method now this method is going to return the process order phase right see it skips moving right so if I am going to do resume here now you can see that particular page is displayed now you see how the flow is going cool easy great so now let me come to my STS again let me stop the stop my server let me come out of debug perspective hopefully this is clear let me remove my debug point you can keep debugging your program it is going to tell you a lot of things right obviously whenever you will go to industry you will learn to run your program you'll always debug your program hopefully see you soon in the industry okay a lot of people who are at you who are actually experienced they might be laughing at me right now because they already understand what I'm trying to do but yes maybe it is boring for you guys you must be telling me come on I will ask do it fast I want to just move on fast but you know what we everyone who is watching this tutorial we need to be on the same pace right basically I'm making this tutorial for the beginners and hopefully they'll find it helpful whenever they'll be going to industry and they'll be working on the actual spring MVC application they're not finding any difficulties hopefully my idea is that my intention is that of making these tutorials just fine right now in application only one last thing is pending whenever we are putting a item name and we are actually clicking this button order we basically need to show the order name in the view pace right so basically we need to capture this particular data whatever the user is entering and that particular data actually we need to show it to the next phase called masala T so basically this particular data here masala tea we need to capture this data in our controller and we need to keep it inside our model and then we need to send that particular model data to the next phase and here in this space we need to capture that particular data which is inside the model object and that particular data is basically whatever your user have entered right here while he is trying to order something right ok guys so this is the thing that we have already developed right so we are hitting home comes last cafe and our dispatcher servlet is actually you know dispatching the request to one of the controller method and this particular method we have already written is actually giving us a welcome face and this welcome page you know actually handled by the dispatcher servlet then actually dispatcher sublet is keeping this particular page to you resolver and the view reservoir is actually giving a exact file location where the dispatcher servlet is going and taking the particular file and giving that particular file to the user so basically we are seeing this particular page right now given by our dispatcher servlet right now we're actually on the process of developing the next phase so basically if you see this particular page here right now whenever we are clicking on order it is basically firing a new URL called slash process order because we are actually trying to place the order by clicking on the order button here right now actually we are in a sending a request to the dispatcher servlet now I dispatch the servlet handle this request obviously home come home come missus is handle this request but this time this request is there a little special to us because we are seeing this for the first time now when the request is coming to the dispatcher servlet is comes with data right this masala T is the data right here so the dispatcher servlet receives the request with some data then the dispatcher servlet finds the subsequent URL process order is fine the match process order request mapping right here is invoked this particular method right here processed order so the dispatcher servlet right now dispatch is request to this particular controller and this particular method gets executed right now in this particular method we need to capture this particular data okay what is passing through from here to here and from here to here now despite a servlet is giving us the data which is entered by the you know user as well right this data right now we can capture it right here we can handle the data right here and we can send the data to the next page okay so right now we can do one thing we can send the data to the dispatcher servlet again if we want to process something and also we can send the actual view name to where we need to send the data okay right now actually the view name will be processed order this is the final page that I want my user to see and in that place I want to send the data which I captured from here right so I gave it back to the dispatcher subnet now dispatch this ability was just a few resolver is finds the process order where the pay's is the view result where again digest job and after that the dispatch sublet is actually going to show me the order received pasted right here the process order phase right here and also it is going to show me the data masala tea that I'm trying to send right from here from this controller okay so when this controller methods does execute we tell the dispatcher servlet this is the particular page that I want my user to see and also I want this data to be available in that particular page as well which is masala tea so you can see this particular data masala tea goes from here to here then here to here here I handle the data and again I sent that particular data I I sent this masala tea data where I actually want to send it I want to send it to the process order page so dispatcher servlet actually detects the data and also dispatch the subject made sure that that particular data is available in my next phase which is this particular page which is process order pairs okay I hope this is clear now let me do it practically which will actually make more sense to you if you do not understand it don't worry just do the program and it will be clear for you now let me switch back to my STS ok so right now let us handle the data whenever somebody click order button right when somebody will enter the foot name and he'll hit the order button then this particular method will be executed at as we have seen already and right here in this particular method what we can do we can handle the data received from the user okay okay so now let me handle the data right here so what I can do here first of all I need the model object and I can write model right here okay and with my model object right now I need to okay set the user data with the model object and send it to view okay okay so right now we need to actually capture the user data right let's say the user is giving the food type is masala tea or if it's giving a food type as masala dosa we need to capture whatever he is entering right so the way we are going to do it is I'm going to follow a approach that you already know we can do it in multiple way we are going to bring in spring later right now you weigh you already know by using the httpservletrequest HTTP or blade request I'm going to hit it and I'm going to say request okay there you go and actually make me remove this okay there you go now the next thing that I'm going to do I'm going to use this request object and I'm going to say get parameter and I'm actually going to provide the parameter name right and the parameter name I'm going to copy it from here where is my name so this is my name food type right foot type is my text box parameter name so now let me go back to here and let me pass my parameter name with a string value control V and this is going to return me whatever the foot type my user has actually entered right there so what I'm going to do here I am going to you know I'm going to handle the return type I can say string user entered value okay and there you go I can capture the value right here and then the next thing is adding adding the captured value to the model okay let me give some white space here so that you guys can see it perfectly okay and let me minimize this so now whatever I captured I'm going to add this particular value to my model so I'm going to go over here and I'm going to say model dot set attribute sorry I'd attribute let me say an attribute right here this particular method and I'm going to give it a give it a name less their user input okay and I'm going to place this particular value whatever I have captured from my user and I'm going to put it right here and I'm going to give it a semicolon right here there you go right now whatever the value that I have attached with my model that particular value will be available with this particular page called process order so now let me go to my process order where is my process order this is the pace okay I'll show you a shortcut you just don't need to sort your purchases like right over here looking East Bay this name or by reading all purchased name what if you 500 pages what if people have 200 pages you cannot look by going through all pages and looking at one by one right what he can do is let's say where I was previously in my mind kappa controller right so let's say I want to go to this particular page so he can select the space you can hit command shift art or control shift R and this is going to find that particular page for you this is going to you know find your resource for you then you double click it okay now there we go you know this is my face now here I'm saying order received and your order is getting processed right and here basically I want to say order received and your order okay whatever you have entered that is getting processed right so what I can say your order then I can give a dollar sign here and I'll dynamically accept that particular value and my value is what this is in my model so let me go to my controller this is what I am actually sending to my view user entered value right this user enter value is whatever my user is entering now that particular value is binded this particular name let me copy this and let me go to my page again let me control shift our with this let me do let me hit enter and let me here let me do what let me in control be it okay and there you go that's done so now if I'm the again is showing error so let me towards it let me open the process order pace again and there you go that error is gone you can ask a clips about it why I'm getting actually a error whenever I'm doing this and right now what I can do is I can start my server right click run is run on server there you go next and finish let's wait my server to start and hopefully it'll be done pretty quickly and ok it's done right now now what I can do here I can go to my web browser then go back and let me let me rephrase it that's fine let mr. masala tea order now and hopefully your order masala tea is getting processed cool so actually the data that I'm entering right here is available in the next phase right now congratulation you are learning well you are learning model well ok now let me go back here let me try something else let me say masala dosa so right now if you're watching this tutorial outside of India you might be thinking what is masala dosa some time you try it it is pretty delicious you can go to any Indian restaurant and you can try masala dosa this is the food basically from South India right now currently I do my job in South India so I know how much how much tasty it is because because those I forgot to have it in South India then you will feel you know the actual taste of it ok so right now if I'm going to do order now your order masala dosa is getting processed this is this is also working right now our thing our code is working fine the only thing that I need to change right now this masala dosa this collar I need to change it to rate so what I can do is I can go back to my Eclipse I can open my process order pace and here this particular thing I can put it inside a span tag span open and actually I end my span right here and what I can do here is I can go to my head tag and right here I can use some styles it I can your style I can use some CSS and I can change the color of this pan so let me copy this and let me say span open and close braces and here right now I can say color equal to rate and font is re Oh well what if how do you spell it a deal Ariel what is that whatever I don't care my thing should work I'm a developer I I work like that masala tea order now and there you go your order masala tea is getting processed cool right okay so right now the things are working as we have expected but only thing is that the font that I have a plaid I think that that is not working perfectly so what I can do is I can go back and I can change it to font family and let's let me give Arial right here let me come here let me refresh it okay now it stains too masala tea now my program is done the things that I want to do that is done but only one thing is pending right now whenever actually I am coming to my project actually this particular thing I need to add it manually right home comes last cafe if I am going to come and exit if I am going to cut it if I'm going to do enter this is my actual project URL right now it is saying a 404 page not found error so how to resolve it so if I go back to my Eclipse if I am going to my web dot XML here you can see whenever my dispatcher servlet is trying to load at the time what is happening it is trying to look for all this file index dot HTML then index dot HTM index dot JSP it is trying to look for all this file one by one if my dispatcher servlet is not finding anyone of this particular file is available in my web content folder then it is giving me a 404 error so right now what I think what I can do here I can copy this particular file index dot JSP I can control C it I can go to my web content I can do a right click new just B file and I can create a index dot JSP files and I can to finish and there you go let me do one thing right now let me go to my index dot JSP pace and here let me give a URL let me give a h1 tag here and let me align this tattoo Center okay and let me say welcome to home calm okay control s to stab it and let me keep a HR here okay and there you go right now let me stop my server can let me restart my server again and you are going to see some magic there okay let me stop my server let me close all the file I don't need this particular files right now I only need the index.jsp file right now let me go to my project and let me do run is run on server and let me start my server as well so now you are going to see something pretty exciting this wait for it okay there you go welcome to home come right now I'm not getting a 404 error right now I can give a link right here and I can say link to mom's café right actually mom's café is home calm class cafe if I hit this URL then this mom's capture page is coming right so now actually I can copy this URL command C to copy this now I can go to index dot JSP and here after the HR I'm going to do what I'm going to create a anchor tag and I'll keep HH r EF h ref and i will paste my link here home comes last cafe link to mom's café okay let me do ctrl s it okay now let's see the magic right now let me go here let me refresh my page let me go back to the previous page let me refresh it okay there you go links to mom cafe if I'm going to click it there you go this particular thing is opening now let's they put type let's try something different let's say biryani okay let me do order now and there you go your order received your order biryani is getting processed cool right everything working good you can test this in your browser you can enter you can refresh it right now you can use this particular page you got a link click this link your your mom's café is getting called and right now click on masala dosa or masala tea order now now this is coming cool now you know what I did right pretty simple pretty straightforward and there you go I want to wrap up this tutorial right now okay cool so right now everything is working for us and I'm pretty happy with the progress that we made and right now it's the turn for you I want you to do the practice along with me right now I want you to do the same program and be comfortable with the complete flow of spring MVC so this particular example will make you comfortable working with model view controller and a complete MVC program you can make out of it right so once you're done with this we are going to do some exciting thing because your basics will be clear then we can then then the things will be pretty easy for us and we will be doing a whole lot of things right so do practice do this example if you want you can send your assignment you can so you can take this as an assignment and you can send your assignment to me to my molarity selenium Express at the res gmail.com or you know you can let me know if you are finding an issue or you got stuck somewhere or you need some help from me right let me know in my email id if I'll be free I'll be definitely assisting you and also if I'm not getting any reply from me you can try pinging me in my Facebook page facebook.com slash selenium Express and I will help you there right so I'll see you there in the next video because it's already one o'clock 116 and tomorrow I have a flight to Bangalore so hopefully I'll catch my flight so let me stop this video right now I'll see you in the next video and take care till then and at the coding bye bye [Music]
Info
Channel: Selenium Express
Views: 43,368
Rating: undefined out of 5
Keywords: spring mvc step by step, spring mvc model, spring mvc project, spring mvc tutorial for beginners, what is model in spring mvc, web app using spring mvc, model view controller spring, spring mvc tutorial, model in mvc, spring real time project, spring mvc by selenium express, selenium express, abhilash, model, spring mvc, java, spring interview questions, spring boot tutorial, spring boot mvc, java mvc, spring annotation tutorial
Id: Y26LegLMvpw
Channel Id: undefined
Length: 57min 25sec (3445 seconds)
Published: Sun Sep 29 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.