-
Spring MVC Internationalization i18n Example
Internationalization is the process of designing your application for the international market; that is, make it able to support virtually any language, timezone or local setting. This tutorial shows how you can build Internationalized i18n web application using Spring MVC.
Date: 2019-08-10 View: 1129
-
Spring MVC Theme Switcher Example
In this tutorial we build a Spring MVC theme. You can apply a Spring MVC theme to set the overall look-and-feel of your web application. A theme is a collection of static resources like images, stylesheets etc.., that affect the look and feel of an application.
Date: 2019-08-10 View: 1203
-
Spring MVC File Upload Example + Validator
In this tutorial we show how to upload a file using Spring MVC and apache commons-fileupload. The uploaded file is validated against a custom Spring Validator. When the file exceeds the maximum allowed upload size, we correctly handle the exception by catching the exception and adding an appropriate message to the response. We’ll show how to upload a single file and also how to upload multiple files.
Date: 2019-08-10 View: 1120
-
Spring MVC Download File Examples
In this tutorial we show you how to use Spring MVC to download a file. You can either download a file as an attachment or directly view the file inside the browser. To show the file directly in the browser, the browser needs to support the specified file type. We demonstrate the file download using multiple methods: via HttpServletResponse, via HttpEntity and via FileSystemResource. We also show you how to handle exceptions while downloading.
Date: 2019-08-10 View: 1253
-
Spring MVC Exception Handling
In this tutorial we take a look at how to use Spring MVC Exception Handling. We can design our application to deal with exceptions in various ways. We could handle the exceptions in the methods where they occur, but most of the time this leads to cluttered and duplicated exception handling code, so we are not showing you this. The following is an overview of what we’ll see in this article:
Date: 2019-08-10 View: 1127
-
Spring MVC Content Negotiation XML JSON
This tutorial shows you how to use Spring MVC Content Negotiation XML JSON features. According to wikipedia, “content negotiation is a mechanism defined in the HTTP specification that makes it possible to serve different versions of a document at the same URI, so that user agents/users can specify which version fit their capabilities the best.”
Date: 2019-08-10 View: 1189
-
Spring MVC RSS ATOM Content Negotiation Example
In this tutorial we show a Spring MVC RSS ATOM Content Negotiation example. Using Content Negotiation we can serve different versions of a document (or resource) at the same URI. Depending on the HTTP Accept header, a path file extension in the URL, a specific request parameter we return a view accordingly or if none of the previous are presented, we fall back on a default view.
Date: 2019-08-10 View: 1001
-
Spring MVC Excel View Example
In this tutorial we demonstrate how to create an Excel view using Spring MVC. By utilizing Spring MVC Content negotiation we can have multiple views of the same resource. This example shows how to create an excel view, either in .xls and .xlsx format. When working with large excel documents it is profitable to use the streaming xlsx view. The streaming view uses less memory and can improve performance of large excel documents.
Date: 2019-08-10 View: 1324
-
Spring MVC PDF View Example
This tutorial demonstrates how to create a PDF view using Spring MVC and itext. Out of the box spring only supports the older com.lowagie:itext library. The newest com.itextpdf:itext library is not supported by default. But there is a work around, which we’ll show you in the following example.
Date: 2019-08-10 View: 1076
-
Spring MVC RESTFul Web Service CRUD Example
In this tutorial we show you how to build a RESTFul Web Service using Spring MVC 4. We create a controller that’ll manage CRUD operations like Create, Read, Update and Delete using the correct HTTP request methods POST, GET, PUT and DELETE respectively. This rest service consumes and produces JSON – JavaScript Object Notation. We enable Cross-origin Resource Sharing by implementing a custom filter to set the correct headers. To evaluate the rest service, we are using a chrome extension named postman.
Date: 2019-08-10 View: 1056
-
Unit Test Spring MVC Rest Service: MockMVC, JUnit, Mockito
Previously we saw how to create a spring mvc restful web service. In this tutorial we continue by showing how to unit test this spring mvc rest service using JUnit, Mockito and Spring Test (MockMVC).
Date: 2019-08-10 View: 1174
-
Spring Boot Thymeleaf Configuration Example
This tutorial demonstrates how to configure Spring Boot and Thymeleaf. We are creating a simple Spring Boot Thymeleaf Example. In this example we configure Spring Boot using application.yml file and place the Thymeleaf templates in the src/main/resources/templates folder. We also utilise org.webjars to load static resources like bootstrap and jquery.
Date: 2019-08-10 View: 1254
-
Spring Kafka Consumer and Producer Example
This tutorial demonstrates how to send and receive messages from Spring Kafka. We start by creating a Spring Kafka Producer which is able to send messages to a Kafka topic. Next we create a Spring Kafka Consumer which is able to listen to messages send to a Kafka topic. We configure both with appropriate key/value serializers and deserializers. Finally we demonstrate the application using a simple Spring Boot application.
Date: 2019-08-10 View: 1277
-
Spring Kafka Adding Custom Header to Kafka Message Example
In this tutorial we demonstrate how to add/read custom headers to/from a Kafka Message using Spring Kafka. We start by adding headers using either Message<?> or ProducerRecord<String, String>. Followed by reading the values inside the KafkaListener using @Header annotation and MessageHeaders class.
Date: 2019-08-10 View: 1795
-
Spring Kafka JSON Serializer and Deserializer Example
The following tutorial demonstrates how to send and receive a Java Object as a JSON byte[] to and from Apache Kafka using Spring Kafka, Spring Boot and Maven. We’ll send a Java Object as JSON byte[] to a Kafka Topic using a JsonSerializer. Afterwards we’ll configure how to receive a JSON byte[] and automatically convert it to a Java Object using a JsonDeserializer.
Date: 2019-08-10 View: 1960