简体   繁体   English

org.springframework.beans.BeanInstantiationException:无法实例化[org.springframework.ui.Model]:指定的类是接口

[英]org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ui.Model]: Specified class is an interface

I am using spring boot. 我正在使用弹簧靴。 My dao implementation is : 我的dao实现是:

public void saveDetails(Proforma_Invoice proforma) {
    Session session = null;
    Transaction tx = null;
    try {
        session = sessionFactory.openSession();
        tx = session.beginTransaction();
        session.saveOrUpdate(proforma);
        tx.commit();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (session != null && session.isOpen())
            session.flush();
        if (session != null && session.isOpen())
            session.close();
    }
}

My controller is : 我的控制器是:

 @RequestMapping(value = "/enquiry", method = RequestMethod.GET)
    public ModelAndView getEnquiryScreen(Model model, Item_entity item, Integer item_code, vendor_entity vendor) {
        System.out.println("Controller is starting..");
        ModelAndView mav = new ModelAndView("enquiry_Screen");
        return mav;
    }

    @RequestMapping(value = "/enquiry", method = RequestMethod.POST)
    public ModelAndView demo(@ModelAttribute("enquiry") Model model, Item_entity item, Integer item_code,
            vendor_entity vendor, Proforma_Invoice proforma) {
        System.out.println("Controller is starting..");
        ModelAndView mav = new ModelAndView("enquiry_Screen"););
        return mav;
    }

Using these when i saving data then i got error : 我在保存数据时使用这些,然后出现错误:

2019-03-12 09:45:34.352 ERROR 7256 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ui.Model]: Specified class is an interface] with root cause

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ui.Model]: Specified class is an interface

Please see the issue. 请查看问题。 and help me to solve the issue. 并帮助我解决问题。

You're trying to mix using a Model as a controller parameter and using @ModelAttribute . 您正在尝试使用Model作为控制器参数和@ModelAttribute @ModelAttribute is used when you have a form object that contains parameters from the incoming request and you want Spring to copy those parameters into an instance of the object. 如果您有一个包含来自传入请求的参数的表单对象,并且希望Spring将这些参数复制到该对象的实例中,则使用@ModelAttribute Either use a form object for your POST mapping (a good idea) or drop the annotation to use Model . 将表单对象用于POST映射(一个好主意),或者删除批注以使用Model

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 bean 实例化失败; 嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 bean 类 - Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class 获取错误org.springframework.beans.BeanInstantiationException: - getting error org.springframework.beans.BeanInstantiationException: bean的实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException: - Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 引起原因:org.springframework.beans.BeanInstantiationException - Caused by: org.springframework.beans.BeanInstantiationException 创建名称为'userRepository'的bean时出错:实例化bean失败; 嵌套的异常是org.springframework.beans.BeanInstantiationException - Error creating bean with name 'userRepository': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException org.springframework.beans.factory.BeanCreationException和org.springframework.beans.BeanInstantiationException,未找到默认构造函数 - org.springframework.beans.factory.BeanCreationException & org.springframework.beans.BeanInstantiationException,No default constructor found 通过构造函数实例化Bean失败; 嵌套的异常是org.springframework.beans.BeanInstantiationException - Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException 通过工厂方法实例化 Bean 失败; 异常 org.springframework.beans.BeanInstantiationException - Bean instantiation via factory method failed; exception org.springframework.beans.BeanInstantiationException 从org.springframework.ui.Model到jQuery的值 - Value from org.springframework.ui.Model to jQuery 无法实例化[org.springframework.data.domain.Pageable]:指定的类是接口 - Failed to instantiate [org.springframework.data.domain.Pageable]: Specified class is an interface
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM