NO WEB.XML ? || Spring MVC Java based configuration || WebApplicationInitializer || Part 2

Veröffentlicht am: 01 Januar 1970
auf dem Kanal: Selenium Express
38,749
713

As we are setting up our spring MVC project with only java code, the first job is to remove any XML file we have. Well, Here is a million-dollar question. Can we run a web app without a web.xml file? If yes, then how? If No, Then why?

Well, the fact is we can deploy a web app without a web.xml file. The only catch is here that we should have the latest servlet container. We should have at least a servlet 3.0 + container to run our web-app to run a java web application.

Now, here comes another question. The web.xml file auto-detected by our webserver. So we do our dispatcher servlet configuration inside the web.xml file. But now as we are going to remove the web.xml file where we are going to write code for dispatcher servlet?

So, We will create a class and, we will implement an interface called WebApplicationInitializer. This interface is given by spring MVC to ensure a code-based configuration. The WebApplicationInitializer ensures that your class will be auto-detected by the webserver like a web.xml file.

The WebApplicationInitializer has a method called on startup that takes a servlet context as an argument. We need to create a dispatcher servlet object and, then we will add it to the servlet context reference. That's it. We are ready to go. The rest will be taken care of by tomcat.

So here is how we can do a spring MVC java based configuration with no web.xml file. The above approach will be a replacement for the web.xml file.

If you are looking for important spring MVC interview questions, It's a good one to prepare.

Any time you are getting stuck with issues, Feel free to ask for support.

#springmvc #WebApplicationInitializer #NoXML

You can send mail to seleniumexpress@gmail.com

you can ping me on my Facebook page.

  / seleniumexpress  

Make sure to join my private Facebook page.

“SeleniumExpress - Support"

you can ask for support in my website forum.

https://www.seleniumexpress.com

Subscribe to my youtube channel.

   / @seleniumexpress  

Music :

-----------

credits : -

(intro)

Adventures by A Himitsu   / a-himitsu  

Creative Commons — Attribution 3.0 Unported— CC BY 3.0

http://creativecommons.org/licenses/b...

Music released by Argofox    • A Himitsu - Adventures [Royalty Free Music]  

Music provided by Audio Library    • Adventures – A Himitsu (No Copyright Music)  



intro template :
   / alexbau01  


Auf dieser Seite können Sie das Online-Video NO WEB.XML ? || Spring MVC Java based configuration || WebApplicationInitializer || Part 2 mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Selenium Express 01 Januar 1970 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 38,749 Mal angesehen und es wurde von 713 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!