org.springframework.beans.BeanInstantiation

我正在使用弹簧靴。我的道实现是:


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();

    }

}

我的控制器是:


 @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;

    }

当我保存数据时使用这些,然后我得到错误:


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

请参阅问题。并帮助我解决问题。


梵蒂冈之花
浏览 99回答 1
1回答

翻过高山走不出你

您正在尝试混合使用 作为控制器参数并使用 . 当您有一个包含来自传入请求的参数的表单对象,并且您希望 Spring 将这些参数复制到该对象的实例中时,将使用该对象。将表单对象用于 POST 映射(一个好主意),或者删除注释以使用 。Model@ModelAttribute@ModelAttributeModel
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java