Spring Interview Question is one of the first things Java programmers should prepare before appearing on any Java or Spring interview. With the immense popularity of Spring frameworks like Spring MVC and Spring Boot in the Java world, the focus on Spring skills on interviews increases daily. For those who don't know, the Spring framework is one of the most famous structures for Java applications, which aims to simplify Java development. It revolutionized the Java development when it initially came with concepts of Dependency Injection and Inversion of Control, which made writing a testable and maintainable Java application.
Learn Java and Programming through articles, code examples, and tutorials for developers of all levels.
Difference between @Controller vs @RestController in Spring Framework
Hello and welcome to the blog post. If you are preparing for Java or Spring Boot
interview, you may have come across this topic. In this article, we are going to
have a look at the difference between @Controller and @RestController
annotation. Let's understand with the help of an example.
Spring Framework is a popular open-source application framework that provides infrastructure support for developing Java applications. One of the essential components of Spring Framework is the controller, which is used to handle HTTP requests and provide responses to clients. In Spring, there are two types of controllers: @Controller and @RestController.
Spring Framework is a popular open-source application framework that provides infrastructure support for developing Java applications. One of the essential components of Spring Framework is the controller, which is used to handle HTTP requests and provide responses to clients. In Spring, there are two types of controllers: @Controller and @RestController.
Difference between @RequestParam and @PathVariable in Spring MVC
Hello guys, if you are wondering what is difference between @ReqestParam and @PathVaraible annotation in Spring MVC, most likely because it was asked to you on a Java and Spring interview or maybe you are just curious then you have come to the right place. In the past, I have talked about difference between @Component, @Service, @Reposistory and @Controller annotations and in this comprehensive article we are going to take an in-depth look at the difference between the two most frequently used annotations in Spring MVC. It provides two commonly used annotations, namely @RequestParam and @PathVariable, which play a significant role in parameter handling within web applications.
Difference between @RequestParam vs @RequestBody in Spring MVC? (with Example)
Hello everyone, in this article, we are going to look at an interesting topic from the Java Spring framework and the topic is, to find the difference between @RequestBody and @RequestParam. If you don't know this is one of the frequently asked Spring MVC interview question and also two of the most used annotation when creating backend of a Java web application in Spring Framework. Earlier, I have explained difference between @RequestBody and @ResponseBody in Spring MVC and REST APIs, and in this article, I am going to tell you the difference between @RequestBody and @RequestParam annotation in Spring Framework. It is worth noting that these two annotations are frequently used in Spring Boot REST API.
10 Examples of RestTemplate in Spring Framework
Hello guys, if you are wondering how to send GET and POST request to your API or Web Service from a Java based Spring Framework then you would be glad to know that You can use use RestTemplate class from Spring Framework. It's a fully functional HTTP client which is really really useful in this age of API. I have used RestTemplate to consume JSON from API before as well as sending different kind of request like POST, PUT, DELETE and PATCH to any REST API. For example, in this article, I shared how to send POST request using RestTemplate and how to set header on HTTP request using RestTemplate. Yes, RestTemplate also allow you to send headers like Authorization on Http Request.
What is ContextLoaderListener in Spring MVC? Example Tutorial
The ContextLoaderListner is one of the essential components of the Spring MVC framework, probably the most important after the DispatcherServlet itself. It is used to create the root context and responsible for loading beans, which are shared by multiple DispatcherServlet like beans related to the service layer and data access layer. In general, When you develop Spring MVC based web applications and also using Spring in the services layer, you need to provide two application-contexts. The first one is configured using ContextLoaderListener, and the other is set using DispatcherServlet. The DispatcherServlet is responsible for loading web component-specific beans like controllers, view resolvers, and handler mappings while, as I said before, ContextLoaderListener is accountable for loading middle-tier and data-tier beans which forms the back end of Spring applications.
How to enable HTTP Caching in Java Web application with Spring MVC? Cache-Control Header Example
One of the standard requirement in a secure Java web application is to disallow the back button of the browser or invalid the session if the user hit the back button of the browser. You might have seen this behavior while doing online banking or net banking, almost all the banks don't allow you to use the browser's back button. Your session gets terminated as soon as you hit the back button, and you have to log in again to do any transaction. Btw, have you ever checked some situations on your Servlet and JSP-based Java web application, like, if you pressed the back button of your browser after logging in, what happened? You will find that the browser takes you to the previous page.
How to send Email in Java using Spring Framework? JavaMailSenderImpl Example Tutorial
Hello guys, if you want to send emails from your Java application and looking for a Java + Spring Framework tutorial to send emails then you have come to the right place. Earlier, I have shared the free spring framework online courses, and today, I am going to share how to send Emails in the Java application using Spring Framework and JavaMailSenderImpl class which makes it really easy to send emails from Java application. Email is one of the essential function of any enterprise Java application. Your application will need Email functionality to send reminders, bills, payments, confirmations, passwords, alerts, and several other kinds of system notifications.
How does HTTP Request is handled in Spring MVC? DispatcherServlet Example Tutorial
One of the common interview questions in Spring MVC is, how does the DispatcherServlet process a request in Spring MVC? or What is the role of DispatcherServlet in the Spring MVC framework? This is an excellent question for any Java or Spring web developer because it exposed the candidate's knowledge about Spring MVC architecture and how its main components like Model, View, and Controller. The answers to this question show how much you know about the Spring MVC framework and its working.
What is the use of DispatcherServlet in Spring MVC? Interview Question Example
Hello guys, In today's article we are going to discuss one interesting and the important Spring MVC concept, which is also a popular Spring Interview question. How DispatcherServlet works internally in Spring MVC or What is the role of DispatcherServlet in Spring MVC are some of the frequently asked Spring MVC Interview Questions. You might have seen them already during your previous Java web development interviews but if you have not, it's a good question to know. In this article, I'll answer these questions by explaining What is DispatcherServlet and its importance in Spring MVC. The DispatcherServlet is one of the important components of the Spring MVC web framework and acts as a Front Controller.
How to use @ResponseBody and @RequestBody in Spring MVC and REST? Example Tutorial
Hello guys, if you are wondering what is
@RequestBody and
@ResponseBody annotation in Spring MVC and Spring Boot then you have come to the right place. Earlier, I have told you
about the
@RestController
annotation and in this article, I am going to explain to you what is RequestBody
and ResponseBody annotation, how to use them, and when to use them with simple examples. While working with REST API, we may need to bind HTTP requests and response bodies
with the domain object. To bind this, we use we can use the @ResponseBody and @RequestBody annotations in Spring MVC.
3 Ways to return different content types from Spring MVC Controller? @RequestMapping and ResponseEntity Example Tutorial
Hello guys, if you want to provide different types from a Controller in Spring
MVC and wondering how to do that then you have come to the right place. In the
past, I have shared the
free Spring MVC courses,
books, and
interview questions
and in this article, I am going to show you three ways to send different
content types from Spring Controller. There are various content types for a
controller and we are going to discuss them in this tutorial. So we are going
to discuss how to interpret the data present in the request and response. JSON
is one of the media formats that may be consumed/produced using this
request-response architecture.
Subscribe to:
Posts (Atom)