Spring Boot MVC and JDBC CRUD Example

Introduction In my other tutorial I had shown how to create an example on Spring MVC and JDBC CRUD example using annotations only, but here I am going to use Spring Boot framework. I did not update the other tutorial keeping in mind if someone still needs the example using Spring framework only. Here also I am going to show you the same example but using Spring Boot framework. We are going to use both gradle and maven build tools to build the application. We are going to see how…

Continue

@WebMvcTest Annotation Example in Spring MVC Applications

Introduction We will see the use of @WebMvcTest annotation in Spring MVC applications. The Spring MVC application may be Spring Boot application as well. The @WebMvcTest annotation can be used not only to test Spring Controllers but also Spring REST Controllers. We will build the applications using both maven and gradle tools. @WebMvcTest annotation is used for unit testing of Spring MVC Applications in situation where the test objective is to just focus on Spring MVC Components. In the snapshot shown below, we want to launch only the ToTestController. All…

Continue

Spring Boot Security – Form Based Authentication

Introduction The example Spring Boot Security form based authentication will show you how to use custom login form with Spring’s j_spring_security_check to authenticate a user. You may also look into form based authentication on Spring MVC framework. The similar example we will implement here but using Spring Boot framework. In the previous example we have also used Resource Bundle that will also help you to make your application internationalization.

Continue

Exception Handling in Spring Web Application

Introduction This post will show you an example on exception handling in Spring web application. In other words, we can also say exception handling in Spring MVC. We will use handle exception on Spring REST APIs but not limited to Spring REST APIs. You can create Spring MVC application and handle the exception same way. We will use @ControllerAdvice and @ExceptionHandler annotations to handle exception in Spring application. Related Posts: Handling Exception in Web Application

Continue

Spring MVC + Angular CRUD Example

In this tutorial we will see the integration of AngularJS with Spring MVC. We are going to create CRUD application using Spring REST API on server side and AngularJS is encapsulated within JSP file on client side. Thus the client will communicate with server asynchronously using AngularJS $http service. If you need PHP version https://www.roytuts.com/angularjs-php-rest-crud-example/ If you need Codeigniter version https://www.roytuts.com/angularjs-codeigniter-rest-crud-example/ Prerequisites Eclipse Neon Maven 3.3.9 Java 1.8 Spring 4.3.8.RELEASE Jackson 2.5.3 AngularJS 1.6.4 The name of the project in Eclipse is angularjs-spring.

Continue

Spring Asynchronous Execution using @Async

Introduction In this tutorial we will discuss about the asynchronous execution support in Spring using the @Async annotation. There are cases in which @Async is necessary to execute piece of code asynchronous. An example would be while sending a (JMS) message from one system to another system. The advantage is that the user does not have to wait for the response while the message is being send. @Async annotation on a method of a bean will execute in a separate thread i.e. the caller does not need to wait for…

Continue

Spring Service Layer Bean Validation

Introduction In my previous tutorial I have shown how to validate input data coming from client or end user to Spring REST Controller. Now in this tutorial I will show you how to validate data in Spring Service Layer. The reason behind validating input data in Service Layer is, input data from client may not always pass through the REST controller method and if you do not validate in Service layer also then unaccepted data may pass through the Service layer causing different issues. Here I will use standard Java…

Continue

Spring MVC Bean Validator

In this example, I will show you how to build a bean validator for User model object.In my previous example, Spring MVC Custom Validator, I have shown how to validate user input. Validating input received from the user to maintain data integrity is an important part of application logic. The Bean Validation model is supported by constraints in the form of annotations placed on a field, method, or class of a JavaBeans component, such as a managed bean. Constraints can be built in or user defined. User-defined constraints are called custom…

Continue

Spring Boot MVC with Tiles and AJAX

In my previous tutorials I have shown how to create a Spring Boot MVC application, here I will show you how to create an AJAX based Spring Boot MVC application with Tiles. What is Tiles (https://tiles.apache.org/) A free open-sourced templating framework for modern Java applications. Based upon the Composite pattern it is built to simplify the development of user interfaces. For complex web sites it remains the easiest and most elegant way to work alongside any MVC technology. In summary, tiles allows authors to define page fragments which can be…

Continue