Home » Spring MVC

Tag Archives: Spring MVC

What is Bean scope in Spring MVC framework with Example

spring-interview-questions-answers

Bean scope in Spring framework or Spring MVC is scope for a bean managed by Spring IOC container. You may know that Spring is a framework that is based on Dependency Injection and Inversion of Control and provides bean management facilities to Java application. In Spring-managed environment bean (Java Classes) are created and wired by the Spring framework. Spring allows ...

Read More »

Spring MVC – HTTP message converter

Quite often you need to provide users with the same data, but in different forms, like JSON, PDF, XLS, etc. If your application is Spring Framework based, this task can be achieved using HTTP message converters. HTTP message converters are applied when HTTP request (or its parts) needs to be converted into type required for handler method argument (see: Handler ...

Read More »

Spring MVC Binding w/o Setters

spring-interview-questions-answers

You can bind form parameters to a domain model object even if the domain model object does not have setters. Just add a @ControllerAdvice class with an @InitBinder method that configures your application to field binding via the initDirectFieldAccess() method package boottests.controllers; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.*; @ControllerAdvice class BindingControllerAdvice { @InitBinder void initBinder(WebDataBinder binder) { binder.initDirectFieldAccess(); } } Here’s how ...

Read More »

Spring with Rails’ jQuery UJS

I’ve always wanted to try to see if I could use Rails’ jQuery UJS in a Spring Boot project. The UJS in jquery-ujs stands for unobtrusive JavaScript. I really like how UJS wires event handlers to eligible DOM elements marked with HTML5 data-* attributes. I find myself wanting to see more of this approach being used in Spring Boot web ...

Read More »

Caching in Spring Boot with Spring Security

java-interview-questions-answers

In this post, I’d like to share a lesson learned by one of the teams at O&B. They were using Spring Boot with Spring Security. By default, anything that is protected by Spring Security is sent to the browser with the following HTTP header: Cache-Control: no-cache, no-store, max-age=0, must-revalidate Essentially, the response will never be cached by the browser. While ...

Read More »

Implementing White-Labelling

java-interview-questions-answers

Sometimes (very often in my experience) you need to support white-labelling of your application. You may normally run it in a SaaS fashion, but some important or high profile clients may want either a dedicated deployment, or an on-premise deployment, or simply “their corner” on your cloud deployment. White-labelling normally includes different CSS, different logos and other images, and different ...

Read More »

Dealing with Domain Objects in Spring MVC

java-interview-questions-answers

I was recently surprised by how one code base had public default constructors (i.e. zero-arguments constructors) in all their domain entities, and had getters and setters for all the fields. As I dug deeper, I found out that the reason why the domain entities are the way they are is largely because the team thinks it was required by the ...

Read More »

Spring MVC Tutorial

spring-interview-questions-answers

1. Introduction As an Enterprise Java Developer, one of the main focus in the job is developing web applications. With a web application, many challenges also come into the picture as consequences. To be specific, some of these are state management, workflow and validations. The HTTP protocol’s stateless nature only make things more complex. The Spring’s web framework is designed ...

Read More »