Home » Tag Archives: Spring MVC

Tag Archives: Spring MVC

Injecting authenticated user into Spring MVC @Controllers

spring-interview-questions-answers

Injecting injecting authenticated user into Spring MVC handler method can be done with @AuthenticationPrincipal annotation and AuthenticationPrincipalArgumentResolver that is an implementation of Spring MVS MethodArgumentResolver. AuthenticationPrincipalArgumentResolver is registered by default with web security configuration (e.g. when you enable security with @EnableWebSecurity). 1. Custom UserDetails Let’s assume we have our custom UserDetails implementation: import org.springframework.security.core.GrantedAuthority; import pl.codeleak.surveyapp.entities.Member; import java.util.Collection; public class ...

Read More »

Thymeleaf 3 – Get Started Quickly with Thymeleaf 3 and Spring MVC

spring-interview-questions-answers

Thymeleaf 3 release arrived. The new version brings plenty of new features like HTML5 support as well as Text templates support with no markup – [# th:utext="${thymeleaf.version}" /] , improved inline capabilities – <p>Thymeleaf [[${thymeleaf.version}]] is great!</p>, performence improvements and much more. The easiest way the get starter with Thymeleaf 3 and Spring MVC is by using Spring MVC 4 ...

Read More »

Spring MVC: Trgger manual validation of a form object

spring-interview-questions-answers

Sometimes it may be needed to use manual validation in Spring MVC @Controller. This is very simple with Spring’s org.springframework.validation.ValidationUtils class. Learn how to invoke a validator in two different scenarios.             Scenario 1 – invoke validation In this scenario, I have a user form with username field. Username field is validated with custom validator ...

Read More »

Configure multiple View Resolvers in Spring

spring-interview-questions-answers

1. Introduction In Spring, the View Resolver is provided to resolve the view with the data available in the model, without tightly binding to a View technology, be it JSP, Velocity or Thymeleaf. Spring makes it easy and flexible to configure one or multiple View Resolvers, as per the need would be. 2. Spring MVC application flow Before we proceed with understanding how ...

Read More »

Integrating JQGrid with Spring MVC and Gson

spring-interview-questions-answers

I was working on a single page application where i wanted to use the grid functionality in one part of the application which was using Spring MVC. It has been some time since i last used JQGrid and finding the information required to get me up and about was bit of a challenge. On this post, I wanted to collate ...

Read More »

Resource versioning with Spring MVC

spring-interview-questions-answers

When serving static resources, it is common practice to append some kind of version information to the resource URL. This allows the browser to cache resources for an unlimited time. Whenever the content of the resource is changed, the version information in the URL is changed too. The updated URL forces the client browser to discard the cached resource and ...

Read More »

Using rx-java Observable in a Spring MVC flow

spring-interview-questions-answers

Spring MVC has supported asynchronous request processing flow for sometime now and this support internally utilizes the Servlet 3 async support of containers like Tomcat/Jetty. Spring Web Async support Consider a service call that takes a little while to process, simulated with a delay: public CompletableFuture<Message> getAMessageFuture() { return CompletableFuture.supplyAsync(() -> { logger.info("Start: Executing slow task in Service 1"); Util.delay(1000); ...

Read More »

Web App Architecture – the Spring MVC – AngularJs stack

spring-interview-questions-answers

Spring MVC and AngularJs together make for a really productive and appealing frontend development stack for building form-intensive web applications.In this blog post we will see how a form-intensive web app can be built using these technologies, and compare such approach with other available options. A fully functional and secured sample Spring MVC / AngularJs web app can be found ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns