春天的论证类型不匹配

时间:2013-01-03 11:05:43

标签: java spring

我正在

java.lang.IllegalArgumentException: argument type mismatch

当我将jsp提交给控制器时。请建议我为什么会收到此错误?

这是StackTrace

java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:426)
at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:414)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:560)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at com.as.brc.filters.LoggingFilter.doFilter(LoggingFilter.java:66)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:619)

我在jsp中使用了commandName

这是我在控制器中使用的

@RequestMapping("/save.do")
    public ModelAndView save(ModelAndView model,@ModelAttribute("classCommand")PurchaseMrn mrn,HttpServletRequest request,HttpServletResponse response,HttpSession session) throws JRException{
        User user=(User)session.getAttribute("loginuser");
        Business business=(Business)session.getAttribute("business");
        System.out.println("Business Is:"+business.getBusinessId());
        mrn.setCreatedBy(user.getId());
        mrn.setCreatedDate(new java.util.Date());
        mrn.setBusinessId(business);
        List<Stock> stockList=new ArrayList<Stock>();
        Stock stock=null;
        int i=0;
        String sid=new String();
        List<Integer> idList=new ArrayList<Integer>();
        List<PurchaseMrnItem> mrnItemsList=new ArrayList<PurchaseMrnItem>();

        List<PurchaseOrder> purchaseList=new ArrayList<PurchaseOrder>();
        int id=0;
        int sno=1;
        long total=0;
        Item item=null;
        for(PurchaseMrnItem mrnItem:mrn.getPurchaseMrnItems()){
            if(request.getParameter("itemId"+i)!=null){
                int itemId=Integer.parseInt(request.getParameter("itemId"+i));
                item=itemsService.findById(itemId, business.getBusinessId());
                mrnItem.setBusinessId(business);
                mrnItemsList.add(mrnItem);
                stock=new Stock(business,mrnItem.getItem(),mrnItem.getRecievedQty(),mrnItem.getAmount());
                stockList.add(stock);
                sid=request.getParameter("id"+i);
                id=Integer.parseInt(sid);
                idList.add(id);
                PurchaseOrder po=new PurchaseOrder(sno,item.getItemName(),item.getUnitType(),mrnItem.getRecievedQty(),mrnItem.getUnitPrice(),mrnItem.getSubtotal());
                purchaseList.add(po);
                total+=mrnItem.getSubtotal();
                sno++;
            }
            i++;
        }
        mrn.setPurchaseMrnItems(mrnItemsList);
        poService.addPOMRN(mrn);
        poService.saveStock(stockList);
        poService.updatePR(idList);
        String prNumber=request.getParameter("prNumber");
        String prDate=request.getParameter("prDate");
        String poDate=request.getParameter("poDate");
        String dcDate=request.getParameter("dcInvoiceDate");

        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("total",total+"");
          parameters.put("poNumber",mrn.getPoNumber()+"");
          parameters.put("dcNumber",mrn.getDcInvoiceNo()+"");
          parameters.put("vehicleNo",mrn.getVehicleNo()+"");
          parameters.put("prNumber",prNumber);
          parameters.put("prDate",prDate);
          parameters.put("poDate",poDate);
          parameters.put("dcDate",dcDate);


          JasperReport report = (JasperReport) JRLoader.loadObject(session
                    .getServletContext().getResourceAsStream(
                            "/WEB-INF/reports/mrn.jasper"));
            JasperPrint prt = JasperFillManager.fillReport(report, parameters,
                    new JRBeanArrayDataSource(purchaseList.toArray()));
            byte[] pdfReport = JasperExportManager.exportReportToPdf(prt);
            //System.out.println("PDF Length Is: "+pdfReport.length);

            Long count=poService.getMRNCount(business.getBusinessId(),Constants.ST_CPMRN);
            String invoiceNumber=business.getShortname()+"/"+Constants.ST_CPMRN+"/"+count;

            Attachment attachment=new Attachment(business,"application/pdf",invoiceNumber,pdfReport,Constants.ST_CPMRN);
          attachemntService.insert(attachment);


        //stockList=null;
        //stock=null;
        model=new ModelAndView("/jsp/stock/ShowPdf.jsp","msg", "Purchases  Added Successfully with MRN Number "+invoiceNumber);
        model.addObject("number",invoiceNumber);
        model.addObject("attachType",Constants.ST_CPMRN);
        return model;
    }

0 个答案:

没有答案