我正在使用彈簧靴。我的道實(shí)現(xiàn)是: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; }當(dāng)我保存數(shù)據(jù)時(shí)使用這些,然后我得到錯(cuò)誤: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 causeorg.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.ui.Model]: Specified class is an interface請(qǐng)參閱問(wèn)題。并幫助我解決問(wèn)題。
1 回答

翻過(guò)高山走不出你
TA貢獻(xiàn)1875條經(jīng)驗(yàn) 獲得超3個(gè)贊
您正在嘗試混合使用 作為控制器參數(shù)并使用 . 當(dāng)您有一個(gè)包含來(lái)自傳入請(qǐng)求的參數(shù)的表單對(duì)象,并且您希望 Spring 將這些參數(shù)復(fù)制到該對(duì)象的實(shí)例中時(shí),將使用該對(duì)象。將表單對(duì)象用于 POST 映射(一個(gè)好主意),或者刪除注釋以使用 。Model
@ModelAttribute
@ModelAttribute
Model
添加回答
舉報(bào)
0/150
提交
取消