Hi!, i’m follow the tutorial hibernate and spring, but i’m want make operate via web with my server tomcat.
Whereby , im create this class:
public class ControllerUser implements Controller {
public ModelAndView handleRequest(HttpServletRequest res,
HttpServletResponse arg1) throws Exception {
// TODO Auto-generated method stub
//ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
//ApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
//BeanFactory beanfactory = new XmlBeanFactory(new ClassPathResource("applicationContext-servlet.xml"));
/*BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource(
"applicationContext-servlet.xml",getClass()));*/
//Persistence persistence = (Persistence) beanfactory.getBean("persistance");
Persistence persistence=new Persistence();
String dato=res.getParameter("dato");
Usuarios user=new Usuarios();
user.setNombre(dato);
user.setCorreo("hola");
user.setIdUsuario(1);
persistence.save(user);
HashMap datos= new HashMap();
datos.put("resp", dato);
System.out.print(datos);
return new ModelAndView("index.jsp","m",datos);
}
}
Have very line in coment, before im try link my applicationcontext-servle but i’m not can make the link :s.
The message error is :
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext-servlet.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext-servlet.xml] cannot be opened because it does not exist