NutzCN Logo
问答 用来接收jsp页面的类,字段类型报错,造成找不到合适的方法
发布于 2365天前 作者 wx_nvu0j53rdpc0ebqbi0kc 1444 次浏览 复制 上一个帖子 下一个帖子
标签:

jsp页面传过来的都是String,接收类里面都是和数据库的字段类型一致,报错?

org.nutz.castor.FailToCastObjectException: Fail to cast from <java.lang.String> to <com.wonders.biz.fl.fljg.xmgl.ssxm.model.DfjgProjectDTO> for {[{"zbType":"1","year":"","region":"","linkMan":"","contactNum":"","practicalType":"11","allotId":"b024cd763e07441bb4ecac7c73c5bd27","quotaName":"养老机构床位","planName":"","planNum":"","address":"","ifSettlement":"","buildingAreaOld":"","bedNumOld":"","buildingAreaNew":"","bedNumNew":"","bedArea":"","investMoney":"","investMoneyTotal":"","investMoneyScale":"","mainPart":"","landAttribute":"","operationMode":"","proposedForm":"","houseProperty":"","isProject":"","startDate":"","nationalTime":"","implementDate":"","endDate":"","planStartTime":"","structuralCappingTime":"","projectEndTime":"","useTime":"","year1":"","region1":"","linkMan1":"","contactNum1":"","practicalType1":"","allotId1":"","quotaName1":"","planName1":"","planNum1":"","address1":"","ifSettlement1":"","buildingAreaOld1":"","bedNumOld1":"","buildingAreaNew1":"","bedNumNew1":"","bedArea1":"","investMoney1":"","investMoneyTotal1":"","investMoneyScale1":"","mainPart1":"","landAttribute1":"","operationMode1":"","proposedForm1":"","houseProperty1":"","isProject1":"","startDate1":"","nationalTime1":"","implementDate1":"","endDate1":"","planStartTime1":"","structuralCappingTime1":"","projectEndTime1":"","useTime1":"","year2":"","region2":"","civilMan":"","civilPhone":"","areaPlanMan":"","areaPlanPhone":"","practicalType2":"","allotId2":"","quotaName2":"","planName2":"","planNum2":"","address2":"","approvedBedNumber":"","investMoney2":"","organType":"","moneyFrom":"","startDate2":"","endDate2":"","year3":"","region3":"","linkMan3":"","contactNum3":"","practicalType3":"","allotId3":"","quotaName3":"","planName3":"","planNum3":"","address3":"","operationMode3":"","buildingAreaOld3":"","investMoney3":"","olderOrganType":"","ifSettlement3":"","isExpansion":"","modifycontent":"","startDate3":"","endDate3":""}]}
	at org.nutz.castor.Castors.cast(Castors.java:262)
	at org.nutz.castor.Castors.castTo(Castors.java:316)
	at org.nutz.mvc.adaptor.injector.ArrayInjector.convertMe(ArrayInjector.java:63)
	at org.nutz.mvc.adaptor.injector.ArrayInjector.get(ArrayInjector.java:51)
	at org.nutz.mvc.adaptor.AbstractAdaptor.adapt(AbstractAdaptor.java:255)
	at org.nutz.mvc.impl.processor.AdaptorProcessor.process(AdaptorProcessor.java:28)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ActionFiltersProcessor.process(ActionFiltersProcessor.java:58)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.ModuleProcessor.process(ModuleProcessor.java:123)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.EncodingProcessor.process(EncodingProcessor.java:27)
	at org.nutz.mvc.impl.processor.AbstractProcessor.doNext(AbstractProcessor.java:44)
	at org.nutz.mvc.impl.processor.UpdateRequestAttributesProcessor.process(UpdateRequestAttributesProcessor.java:15)
	at org.nutz.mvc.impl.NutActionChain.doChain(NutActionChain.java:44)
	at org.nutz.mvc.impl.ActionInvoker.invoke(ActionInvoker.java:67)
	at org.nutz.mvc.ActionHandler.handle(ActionHandler.java:31)
	at org.nutz.mvc.NutFilter.doFilter(NutFilter.java:202)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.nutz.lang.born.BorningException: Fail to born or cast to 'com.wonders.biz.fl.fljg.xmgl.ssxm.model.DfjgProjectDTO'
 by args: [@([{"zbType":"1","year":"","region":"","linkMan":"","contactNum":"","practicalType":"11","allotId":"b024cd763e07441bb4ecac7c73c5bd27","quotaName":"养老机构床位","planName":"","planNum":"","address":"","ifSettlement":"","buildingAreaOld":"","bedNumOld":"","buildingAreaNew":"","bedNumNew":"","bedArea":"","investMoney":"","investMoneyTotal":"","investMoneyScale":"","mainPart":"","landAttribute":"","operationMode":"","proposedForm":"","houseProperty":"","isProject":"","startDate":"","nationalTime":"","implementDate":"","endDate":"","planStartTime":"","structuralCappingTime":"","projectEndTime":"","useTime":"","year1":"","region1":"","linkMan1":"","contactNum1":"","practicalType1":"","allotId1":"","quotaName1":"","planName1":"","planNum1":"","address1":"","ifSettlement1":"","buildingAreaOld1":"","bedNumOld1":"","buildingAreaNew1":"","bedNumNew1":"","bedArea1":"","investMoney1":"","investMoneyTotal1":"","investMoneyScale1":"","mainPart1":"","landAttribute1":"","operationMode1":"","proposedForm1":"","houseProperty1":"","isProject1":"","startDate1":"","nationalTime1":"","implementDate1":"","endDate1":"","planStartTime1":"","structuralCappingTime1":"","projectEndTime1":"","useTime1":"","year2":"","region2":"","civilMan":"","civilPhone":"","areaPlanMan":"","areaPlanPhone":"","practicalType2":"","allotId2":"","quotaName2":"","planName2":"","planNum2":"","address2":"","approvedBedNumber":"","investMoney2":"","organType":"","moneyFrom":"","startDate2":"","endDate2":"","year3":"","region3":"","linkMan3":"","contactNum3":"","practicalType3":"","allotId3":"","quotaName3":"","planName3":"","planNum3":"","address3":"","operationMode3":"","buildingAreaOld3":"","investMoney3":"","olderOrganType":"","ifSettlement3":"","isExpansion":"","modifycontent":"","startDate3":"","endDate3":""}])]
 because: No suitable Constructor or Factory Method!!
	at org.nutz.lang.Mirror.born(Mirror.java:988)
	at org.nutz.castor.castor.String2Object.cast(String2Object.java:16)
	at org.nutz.castor.castor.String2Object.cast(String2Object.java:9)
	at org.nutz.castor.Castors.cast(Castors.java:252)
	... 39 more
  private String zbType;// 指标类型

    private String id;// 主键
    private String allotId;// 指标下达ID,外键到 DFJG_QUOTA_ALLOT.ID
    private String quotaName;//指标名称
    private String year;// 年度
    private String region;// 所在街道
    private String address;// 地址
    private String linkMan;// 联系人
    private String contactNum;// 联系电话
    private String practicalType;// 实事类型(00:当年度非实事项目,01非实事项目储备项目11:当年度实事项目10实事项目储备项目)
    private Date startDate;// 拟开工/已开工日期
    private Date endDate;// 拟竣工/已竣工日期
    private Double planNum;// 指标数
    private String planName;// '项目名称
    private String ifSettlement;// 是否在大型居住区内(填是/否)
    private double buildingAreaOld;// 建筑面积(原有
    private double buildingAreaNew;// '建筑面积(新增)
    private int bedNumOld;// 拟设床位数(张)(原有)
    private int bedNumNew;// '拟设床位数(张)(新增)
    private double bedArea;// 床均建筑面积
    private double investMoney;// 拟投资额(万元、/总资额(万元)
    private double investMoneyTotal;// 至当月累计完成投资(万元)
    private double investMoneyScale;// 至当月累计完成投资占年投资比
    private String mainPart;// 投入主体(单位名称)
    private String landAttribute;// 土地属性
    private String operationMode;// 运营方式:公建公营、公建民营、“民办民非”、“民办工商”

    private Date nationalTime;//发改委立项日期

    private String year1;// 年度
    private String allotId1;// 指标下达ID,外键到 DFJG_QUOTA_ALLOT.ID
    private String quotaName1;//指标名称
    private String practicalType1;// 实事类型(00:当年度非实事项目,01非实事项目储备项目11:当年度实事项目10实事项目储备项目)
    private String region1;// 所在街道
    private String address1;// 地址
    private Date startDate1;// 拟开工/已开工日期
    private Date endDate1;// 拟竣工/已竣工日期
    private Double planNum1;// 指标数
    private String planName1;// '项目名称
    private String linkMan1;// 联系人
    private String contactNum1;// 联系电话
    private String ifSettlement1;// 是否在大型居住区内(填是/否)
    private double investMoney1;// 拟投资额(万元、/总资额(万元)
    private String operationMode1;// 运营方式:公建公营、公建民营、“民办民非”、“民办工商”
    private double buildingAreaOld1;// 建筑面积(原有
    private Date nationalTime1;//发改委立项日期

    private String year2;// 年度
    private String allotId2;// 指标下达ID,外键到 DFJG_QUOTA_ALLOT.ID
    private String quotaName2;//指标名称
    private String practicalType2;// 实事类型(00:当年度非实事项目,01非实事项目储备项目11:当年度实事项目10实事项目储备项目)
    private String region2;// 所在街道
    private String address2;// 地址
    private Date startDate2;// 拟开工/已开工日期
    private Date endDate2;// 拟竣工/已竣工日期
    private Double planNum2;// 指标数
    private String planName2;// '项目名称
    private double investMoney2;// 拟投资额(万元、/总资额(万元)

    private String year3;// 年度
    private String allotId3;// 指标下达ID,外键到 DFJG_QUOTA_ALLOT.ID
    private String quotaName3;//指标名称
    private String practicalType3;// 实事类型(00:当年度非实事项目,01非实事项目储备项目11:当年度实事项目10实事项目储备项目)
    private String region3;// 所在街道
    private String linkMan3;// 联系人
    private String contactNum3;// 联系电话
    private String address3;// 地址
    private Date startDate3;// 拟开工/已开工日期
    private Date endDate3;// 拟竣工/已竣工日期
    private Double planNum3;// 指标数
    private String planName3;// '项目名称
    private double investMoney3;// 拟投资额(万元、/总资额(万元)
    private String operationMode3;// 运营方式:公建公营、公建民营、“民办民非”、“民办工商”
    private double buildingAreaOld3;// 建筑面积(原有
    private String ifSettlement3;// 是否在大型居住区内(填是/否)

    private String proposedForm;// 拟建形式:新建、改扩建、改造
    private String houseProperty;// 房屋属性:产权、使用权、租赁、其他
    private String isProject;// 是否发改委立项(0是否,1是市发改委,2是区发改委)
    private Date implementDate;// 拟执业/已执业时间
    private Date planStartTime;// 施工计划:正式开工时间
    private Date structuralCappingTime;// 施工计划:结构封顶时间
    private Date projectEndTime;// 施工计划:工程结束时间
    private Date useTime;// 施工计划:正式使用时间

    private double buildingAreaNew1;// '建筑面积(新增)
    private int bedNumOld1;// 拟设床位数(张)(原有)
    private int bedNumNew1;// '拟设床位数(张)(新增)
    private double bedArea1;// 床均建筑面积
    private double investMoneyTotal1;// 至当月累计完成投资(万元)
    private double investMoneyScale1;// 至当月累计完成投资占年投资比
    private String mainPart1;// 投入主体(单位名称)
    private String landAttribute1;// 土地属性
    private String proposedForm1;// 拟建形式:新建、改扩建、改造
    private String houseProperty1;// 房屋属性:产权、使用权、租赁、其他
    private String isProject1;// 是否发改委立项(0是否,1是市发改委,2是区发改委)
    private Date implementDate1;// 拟执业/已执业时间
    private Date planStartTime1;// 施工计划:正式开工时间
    private Date structuralCappingTime1;// 施工计划:结构封顶时间
    private Date projectEndTime1;// 施工计划:工程结束时间
    private Date useTime1;// 施工计划:正式使用时间

    private String olderOrganType;// 养老机构类型(0市级1区级2镇村3民营)
    private String modifycontent;// 改造内容(0配电场所1配电设备2配电线路3,可多选)
    private String isExpansion;// 是否扩容(0否1是)

    private String civilMan;// 区民政联系人
    private String civilPhone;// 区民政联系电话
    private String areaPlanMan;// 区卫计委民政联系人
    private String areaPlanPhone;// 区卫计委联系电话
    private Int approvedBedNumber;// 核定床位数
    private String organType;// 医疗机构类型(0护理院1门诊部2医务室3护理站4卫生所5保健站)
    private String moneyFrom;// 资金来源

    private Date createDate;
    private Date updateDate;


    private Integer projectId;// '外键,关联项目
    private String allCompleted;// 项目整理完成比例
    private Date certificateDate;// 养老机构设立许可证发放日期
    private String currentProgress;// (目前进度:0前期准备1施工招投标2施工改造,设备构造3工程结束4竣工验收5改造装修,设备购置,6申请执业许可7取得医疗机构执业许可证)
    private Date completeDate;// 完成日期
    private String propose;// 推进难点及相关建议
    private String remark;// 备注'
    private String earlyFormalities;// 前期手续办理(%)
    private int civilCompleted;// 土建工程所处阶段(0:未开始,1地下层施工,2地面层施工3结构封顶4土建工程完成)
    private int insideCompleted;// 内部装修完成(%)
    private int greenCompleted;// 环境绿化完成(%)
    private int equipmendCompleted;// 设备添置完成(%)
    private int lienceCompleted;// 立项(%)
    private int filing;// 方案设计(%)
    private int solutionDesign;// 施工招投标(%)
    private int construction;// '施工许可证办理(%)
8 回复

仔细看看适配器的文档

适配器应该是对的,因为之前是调通的,之后加了东西

 @At
    @Filters
    @Ok("json")
    public String saveProject(@Param("data")DfjgProjectDTO[] dfjgProjectDTO){
        String result  = ssProjectManage.saveProject(dfjgProjectDTO);
        return "success";
    }

你没看文档的样子,要用前缀表单"::"或者pojo适配的".."

但是我jsp页面,是这样的啊,传到后台的是个数组,这样写应该对吧?

 function editSubmit(btn){
        var form = new mini.Form("edit_user_form");
        form.validate();
        if (form.isValid() == false){
            mini.get("save").enable();//如果表单校验失败,则保存按钮仍可用
            return;
        }
        var o = form.getData(true);
        var json = mini.encode([o]);

        $.ajax({
            url: "<%=request.getContextPath()%>/ssProjectAt/saveProject",
            data: {data:json},
            dataType:"json",
            type: "post",
            success: function (text) {
                if(text.total==1){
                    var param=text.param;
                    mini.confirm("该年度此指标已存在,是否更新指标数据?", "确定",function (action) {
                        if (action == "ok"){
                            updateInfo(json,param);
                        }
                    });
                }else{
                    mini.alert("提交成功!");
                }

                //	CloseWindow();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                window.location.href="<%=request.getContextPath()%>/exception/error.jsp";
            }
        });
    }

把接收数据类,字段全部改为String就可以了,唉,还要转,麻烦

复杂表单,用 data : jsonStr 和JsonAdapter

尝试用这个JsonAdapter,但是文档适配器这一节,对这个的描述有点少啊,问答里面 也不多,我还是先把他们都改回String吧,一直想不通同一个方法为啥之前可以调通,现在不行了。唉 ,有空再研究吧

添加回复
请先登陆
回到顶部