My controller class is in com.tps.sphbIntegration.controllers package
My applicationContext.xml file is in WEB-INF/spring/applicationContext.xml
In the controller class:
@Controller @RequestMapping("jsp") public class SpringController { @RequestMapping(value="register.html" , method = RequestMethod.POST) public String enterSucess(@Valid Login login , BindingResult result , Map model,HttpSession session){ if(result.hasErrors()){ System.out.println("Error happened..."); return "register"; }else{ System.out.println("I am an controller for get method of jsp/success.html "); login = (Login) model.get("login"); session.setAttribute("empId", login.getEmpId()) ; session.setAttribute("empName", login.getEmpName()) ; session.setAttribute("empPassword", login.getEmpPassword()) ; //session.setAttribute("empGender", login.getGender()) ; //session.setAttribute("empType", login.getEmpType()) ; ApplicationContext factory = new ClassPathXmlApplicationContext("spring/applicationContext.xml"); EmployeeDao dao=(EmployeeDao)factory.getBean("d"); dao.saveEmployee(login); return "registerCheck"; } } } When execution I got the exception as
java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist Please help me to set the path of applicationContext.xml in the controller or give some example that how to access the applicationContext.xml in controller.