我的控制器类在 com.tps.sphbIntegration.controllers
包中
我的 applicationContext.xml 文件在WEB-INF/spring/applicationContext.xml
在控制器类中:
@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";
}
}
}
执行时我得到了异常
java.io.FileNotFoundException: class path resource [spring/applicationContext.xml] cannot be opened because it does not exist
请帮我设置applicationContext.xml
控制器中的路径或举例说明如何访问applicationContext.xml
控制器。