Spring Security : check whether you have multiple ContextLoader* definitions in your web.xml!

Table of ContentsProblem:Trace:Solution: Problem: public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { public SecurityWebApplicationInitializer(){ super(SpringSecurityWebConfig.class); } } Trace: java.lang.IllegalStateException: Cannot initialize context because there is already a root application context present -…

spring mvc configure custom error pages

How to configure error page in spring

Table of ContentsErrorController.javaweb.xml404.jsp500.jsp ErrorController.java package com.springdemo; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @Controller @RequestMapping(“/”) public class ErrorController { @RequestMapping(value = “404”,method = RequestMethod.GET) public String Page404(ModelMap model) {…

JSTL forEach Loop Example

Table of ContentsMaven Dependency:Controller:JSP Page: Maven Dependency: <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> Controller: @RequestMapping(value = “jstlForEach”, method = RequestMethod.GET) public String jstlForEach(ModelMap model) { List<Employee> employees = new ArrayList<>(); employees.add(new…

JSTL c:out example

JSTL Maven Dependency: <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency> Controller @Controller @RequestMapping(“/”) public class HelloController { @RequestMapping(value = “out”,method = RequestMethod.GET) public String printWelcome(ModelMap model) { model.addAttribute(“message”, “Hello JSTL!”); return “out”;…

HIBERNATE CUSTOM RESULT TRANSFORMER

Hibernate Custom Result Transformer

Table of ContentsWhat is need of Hibernate Custom Result Transformer?CustomTransformer.javaHow to use Custom Transformer:Output: What is need of Hibernate Custom Result Transformer? Hibernate provide AliasToBean result transformer, it will be…

Spring MVC cron scheduler

Spring MVC cron scheduler

During application development we require some task should be executed automatically based on particular time interval. for example for banking application credit card bill should be generated by 1st date…