Spring MVC Tutorial

spring-mvc thumbnail

Any modern java web application cannot be thought of creating without spring. It's not like it is not possible to create but coding in a plain servlet is a pain. Spring MVC provides clear separation and excellent integration between all the modules. The different annotations such as @Component, @Controller and many more have really made developer life easier while dealing with java web application.

In the below tutorials we have tried to cover all the topics that are required to develop a java web application using spring mvc.

Spring MVC Content Negotiating Viewresolver Example(Json, XML, HTML)

By Dhiraj 26 March, 2017 18K

This tutorial explains about contentnegotiatingviewresolver in spring mvc using annotations and java configs. Here we will have a single controller that can produce responses in different data format such as json, html or xml etc. based on the request url without creating any extra layers. We only require to have contentnegotiatingviewresolver configurations that will do this for us. Now, let us implement this with the following spring mvc contentnegotiatingviewresolver example. In this example we will have responses in json, xml and html based on the request file name....

Read now➤

RSA Encryption in Javascript and Decryption in Java

By Dhiraj 20 February, 2020 66K

In this article, we will learn how to perform RSA encryption in Javascript and decrypt in Java. At the client-side, we will build a sample login form with HTML and Javascript with Angular JS and while...

Read now➤

Spring Azure Blob Storage

By Dhiraj 13 October, 2019 33K

In this article, we will be discussing creating a storage account on Microsoft Azure and create a sample spring-mvc based java application to perform different operations on Azure blob storage....

Read now➤

3 Ways to Add Custom Header in Spring SOAP Request

By Dhiraj 09 March, 2019 135K

In this article, we will check out 3 different ways to add a custom header in Spring SOAP(Simple Object Access Protocol) request. In my last article, we created a Spring Boot SOAP client and then discussed about handling exceptions in it. Now, let us add a custom header in the request. This is mostly needed to add authentication related details in the header while invoking SOAP web services....

Read now➤

Exception Handling In Spring Soap Client

By Dhiraj 27 February, 2019 53K

WebServiceTemplate already handles an exception in a perfect way but sometimes it is required to add our custom logic while executing the exception callbacks as most of the web services are designed in a such a way that exceptions are thrown in a custom fashion. For example, many web services tend to provide a status of 200 even during exceptions and there is a nested status code which actually tells about the exception. In that case, default exception handling provided by WebServiceTemplate is unable to handle that....

Read now➤

AWS S3 Java

By Dhiraj 30 December, 2018 24K

In this tutorial, we will discuss AWS S3 and create a sample java application to perform different file operations such as folder create, read, write and delete files from an AWS S3 bucket. We will start from creating an S3 bucket on AWS, how to get access key id and secret access key of Amazon S3 account and then use these keys in our spring application to perform different operations on S3....

Read now➤

Spring MVC PayuMoney Integration

By Dhiraj 04 August, 2018 30K

In this article, we will be discussing about payumoney payment gateway integration with spring mvc app. To make our spring MVC configuration simple, we will be generating spring boot application. For client side, we will be using Thymeleaf along with AngularJS 1 to bind our model object with html....

Read now➤

Storing Hashed Password to Database in Java(Using Bcrypt)

By Dhiraj 07 May, 2017 71K

Storing passwords in plain text in databse is vulnerable to security. This article is about storing hashed password to databse in java. Doing so it becomes impossible for even BDAs to extract the real passwords. There are many hashing algorithms such as MD5, SHA-1, SHA-2 etc to hash a password but adding a salt to the password provides extra security. In this article we will be using jBCrypt, which internally generates a random salt while encoding passwords, to encode our plain text passwords and store in DB....

Read now➤

Spring MVC PDF and Excel View Example (using iText)

By Dhiraj 05 April, 2017 26K

This tutorial explains about generating PDF and excel documents in Spring web mvc using iText PDF library. It uses the content negotiation view resolver provided by spring to generate PDF and excel views. Here we will be creating a simple spring mvc web application using annotations and java configs. This application will be capable of negotiating views between pdf and excel based on the HTTP request. If you are looking for json, xml and html content view resolver then...

Read now➤

Spring JMS Example + ActiveMQ + Annotation/ JavaConfig

By Dhiraj 07 November, 2016 75K

Today let us integrate JMS and Spring with activemq with an example. This will be a simple JMS producer and consumer app. Before we start let's make some concepts clear. Java Message Service (JMS) is an application program interface (API) that supports the formal....

Read now➤

Spring MVC annotation Example with JavaConfig

By Dhiraj 25 March, 2017 38K

This tutorial aims to provide a complete guide for spring mvc. We will be developing a web app using spring mvc and try to learn spring mvc architecture, its configurations and different concepts involved while creating a spring mvc annotation example. All the configurations will be based on annotations and java config and we will be overriding methods defined in WebApplicationInitializer and WebMvcConfigurerAdapter class to achieve this....

Read now➤

Different AOP Terminologies and Keywords

By Amit Swain 28 January, 2017 11K

In this post, let us discuss about different Aspect Oriented Programming(AOP) terminologies which will help to understand the upcoming spring AOP tutorials.It is very much important to understand the basic AOP terms and usage first to understand the internals of AOP, it's implementation and usage using Spring framework.The AOP terminologies described here are not specific to...

Read now➤

Spring 5 Features and Enhancements

By Dhiraj 24 January, 2017 14K

As we all must be knowing the second milestone of Spring Framework 5.0 got released in September last year as a new functional web framework.It is completely based on Reactive Programming Model.Spring Framework 5.0 has many major enhancements and upgrades with Java 8 as a minimum...

Read now➤

Caching in Spring Example + Ehcache + Cacheable + Annotation/JavaConfig

By Dhiraj 25 November, 2016 25K

As we know EhCache is a widely used caching library. Spring provides easy annotation based integration mechanism of ehcache using @Cacheable. Here we will be creating a sample application which will use @Cacheable annotation to cache the user detail. We will try to fetch the same user detail again and again and compare the time required t fetch it. The spring configuration...

Read now➤

Writing Junit Tests with Spring4 Mvc

By Dhiraj 19 November, 2016 61K

Today we will take a look into writing Junit test cases with Spring Mvc. We will be creating a sample Spring MVC app with hibernate and write few test cases using Junit and clear our...

Read now➤

spring4 hibernate integration example + annotation / Java Config

By Dhiraj 19 November, 2016 28K

There are numerous spring hibernate intgration example available on the web but most of them are not using java configuration. But many spring app these days are being developed using java config. Hnce, today we will be dicussing about spring hibernate integration with complete java configguration, no xml at all. This post can be considered as an upgradation of my previous post where we discussed Spring AngularJS intgration but without DB connection...

Read now➤

spring mvc + angularjs integration example + annotation/JavaConfig

By Dhiraj 13 November, 2016 25K

This post provides an example of spring mvc and angularjs integration. Here we will be using annotation based spring configuration with Beans defined in Java. We will be creating a simple single page application to show the user details in a bootstrap table after a successful login....

Read now➤