SpringMVC 前后台参数传递问题 5C

前端参数为:var jsonData = {
"id":id,
"jsonDateForDetail":jsonDateForDetail,
"contractCode":contractCode,
"contractName":contractName,
"contractType":contractType,
"signingDate":signingDate,
"shipperId":shipperId,
"shipperName":shipperName,
"companyAbbreviation":companyAbbreviation,
"carrierId":carrierId,
"carrierName":carrierName,
"shipperContactPerson":shipperContactPerson,
"shipperContactNumber":shipperContactNumber,
"carrierContactPerson":carrierContactPerson,
"carrierContactNumber":carrierContactNumber,
"cashOnDeliveryRatio":cashOnDeliveryRatio,
"settlementMethod":settlementMethod,
"departureAddress":departureAddress,

"arrivalAddress":arrivalAddress,
"consignmentPeriod":consignmentPeriod,
"shippingType":shippingType,
"deliveryMode":deliveryMode,
"numConfirmationMethod":numConfirmationMethod,
"qaConfirmationMethod":qaConfirmationMethod,
"remark":remark,
"status":status,
"contractProvision":contractProvision,
"auditPerson":auditPerson,
"auditTime":auditTime,
"auditOpinion":auditOpinion,
//后加的
"flag":flag
};

Wb.request({
url:reqUrl ,
params: jsonData,
success: function(resp) {
app.appwin.hide();
app.appwinAudit.hide();
app.appgrid.store.reload();

if(oprType=="audit"){

Ext.Msg.alert('{#app_alert#}', "审核通过");
}else{
Ext.Msg.alert('{#app_alert#}', "保存成功");
}
}
});

我新增的实体类:
public class TransportVo extends RmValueObject{
private static final long serialVersionUID = 1L;
private String id;

private String contractCode;

private String contractType;

private String contractName;

private Timestamp signingDate;

private String shipperId;

private String shipperName;

private String companyAbbreviation;

private String carrierId;

private String carrierName;

private String shipperContactPerson;

private String shipperContactNumber;

private String carrierContactPerson;

private String carrierContactNumber;

private BigDecimal cashOnDeliveryRatio;

private String settlementMethod;

private String departureAddress;

private String arrivalAddress;

private String consignmentPeriod;

private String shippingType;

private String deliveryMode;

private String numConfirmationMethod;

private String qaConfirmationMethod;

private String remark;

private String status;

private String auditPerson;

private Timestamp auditTime;

private String auditOpinion;

private String usableStatus;

private Timestamp createTime;

private String createIp;

private String createUserId;

private String createUserName;

private Timestamp modifyTime;

private String modifyIp;

private String modifyUserId;

private String modifyUserName;

private Timestamp deleteTime;

private String deleteIp;

private String deleteFlag;

private String deleteUserId;

private String deleteUserName;

private String orderCode;

private String attribute1;

private String attribute2;

private String attribute3;

private String attribute4;

private String contractProvision;

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getContractCode() {
    return contractCode;
}

public void setContractCode(String contractCode) {
    this.contractCode = contractCode;
}

public String getContractType() {
    return contractType;
}

public void setContractType(String contractType) {
    this.contractType = contractType;
}

public String getContractName() {
    return contractName;
}

public void setContractName(String contractName) {
    this.contractName = contractName;
}

public Timestamp getSigningDate() {
    return signingDate;
}

public void setSigningDate(Timestamp signingDate) {
    this.signingDate = signingDate;
}

public String getShipperId() {
    return shipperId;
}

public void setShipperId(String shipperId) {
    this.shipperId = shipperId;
}

public String getShipperName() {
    return shipperName;
}

public void setShipperName(String shipperName) {
    this.shipperName = shipperName;
}

public String getCompanyAbbreviation() {
    return companyAbbreviation;
}

public void setCompanyAbbreviation(String companyAbbreviation) {
    this.companyAbbreviation = companyAbbreviation;
}

public String getCarrierId() {
    return carrierId;
}

public void setCarrierId(String carrierId) {
    this.carrierId = carrierId;
}

public String getCarrierName() {
    return carrierName;
}

public void setCarrierName(String carrierName) {
    this.carrierName = carrierName;
}

public String getShipperContactPerson() {
    return shipperContactPerson;
}

public void setShipperContactPerson(String shipperContactPerson) {
    this.shipperContactPerson = shipperContactPerson;
}

public String getShipperContactNumber() {
    return shipperContactNumber;
}

public void setShipperContactNumber(String shipperContactNumber) {
    this.shipperContactNumber = shipperContactNumber;
}

public String getCarrierContactPerson() {
    return carrierContactPerson;
}

public void setCarrierContactPerson(String carrierContactPerson) {
    this.carrierContactPerson = carrierContactPerson;
}

public String getCarrierContactNumber() {
    return carrierContactNumber;
}

public void setCarrierContactNumber(String carrierContactNumber) {
    this.carrierContactNumber = carrierContactNumber;
}

public BigDecimal getCashOnDeliveryRatio() {
    return cashOnDeliveryRatio;
}

public void setCashOnDeliveryRatio(BigDecimal cashOnDeliveryRatio) {
    this.cashOnDeliveryRatio = cashOnDeliveryRatio;
}

public String getSettlementMethod() {
    return settlementMethod;
}

public void setSettlementMethod(String settlementMethod) {
    this.settlementMethod = settlementMethod;
}

public String getDepartureAddress() {
    return departureAddress;
}

public void setDepartureAddress(String departureAddress) {
    this.departureAddress = departureAddress;
}

public String getArrivalAddress() {
    return arrivalAddress;
}

public void setArrivalAddress(String arrivalAddress) {
    this.arrivalAddress = arrivalAddress;
}

public String getConsignmentPeriod() {
    return consignmentPeriod;
}

public void setConsignmentPeriod(String consignmentPeriod) {
    this.consignmentPeriod = consignmentPeriod;
}

public String getShippingType() {
    return shippingType;
}

public void setShippingType(String shippingType) {
    this.shippingType = shippingType;
}

public String getDeliveryMode() {
    return deliveryMode;
}

public void setDeliveryMode(String deliveryMode) {
    this.deliveryMode = deliveryMode;
}

public String getNumConfirmationMethod() {
    return numConfirmationMethod;
}

public void setNumConfirmationMethod(String numConfirmationMethod) {
    this.numConfirmationMethod = numConfirmationMethod;
}

public String getQaConfirmationMethod() {
    return qaConfirmationMethod;
}

public void setQaConfirmationMethod(String qaConfirmationMethod) {
    this.qaConfirmationMethod = qaConfirmationMethod;
}

public String getRemark() {
    return remark;
}

public void setRemark(String remark) {
    this.remark = remark;
}

public String getStatus() {
    return status;
}

public void setStatus(String status) {
    this.status = status;
}

public String getAuditPerson() {
    return auditPerson;
}

public void setAuditPerson(String auditPerson) {
    this.auditPerson = auditPerson;
}

public Date getAuditTime() {
    return auditTime;
}

public void setAuditTime(Timestamp auditTime) {
    this.auditTime = auditTime;
}

public String getAuditOpinion() {
    return auditOpinion;
}

public void setAuditOpinion(String auditOpinion) {
    this.auditOpinion = auditOpinion;
}

public String getUsableStatus() {
    return usableStatus;
}

public void setUsableStatus(String usableStatus) {
    this.usableStatus = usableStatus;
}

public Date getCreateTime() {
    return createTime;
}

public void setCreateTime(Timestamp createTime) {
    this.createTime = createTime;
}

public String getCreateIp() {
    return createIp;
}

public void setCreateIp(String createIp) {
    this.createIp = createIp;
}

public String getCreateUserId() {
    return createUserId;
}

public void setCreateUserId(String createUserId) {
    this.createUserId = createUserId;
}

public String getCreateUserName() {
    return createUserName;
}

public void setCreateUserName(String createUserName) {
    this.createUserName = createUserName;
}

public Date getModifyTime() {
    return modifyTime;
}

public void setModifyTime(Timestamp modifyTime) {
    this.modifyTime = modifyTime;
}

public String getModifyIp() {
    return modifyIp;
}

public void setModifyIp(String modifyIp) {
    this.modifyIp = modifyIp;
}

public String getModifyUserId() {
    return modifyUserId;
}

public void setModifyUserId(String modifyUserId) {
    this.modifyUserId = modifyUserId;
}

public String getModifyUserName() {
    return modifyUserName;
}

public void setModifyUserName(String modifyUserName) {
    this.modifyUserName = modifyUserName;
}

public Date getDeleteTime() {
    return deleteTime;
}

public void setDeleteTime(Timestamp deleteTime) {
    this.deleteTime = deleteTime;
}

public String getDeleteIp() {
    return deleteIp;
}

public void setDeleteIp(String deleteIp) {
    this.deleteIp = deleteIp;
}

public String getDeleteFlag() {
    return deleteFlag;
}

public void setDeleteFlag(String deleteFlag) {
    this.deleteFlag = deleteFlag;
}

public String getDeleteUserId() {
    return deleteUserId;
}

public void setDeleteUserId(String deleteUserId) {
    this.deleteUserId = deleteUserId;
}

public String getDeleteUserName() {
    return deleteUserName;
}

public void setDeleteUserName(String deleteUserName) {
    this.deleteUserName = deleteUserName;
}

public String getOrderCode() {
    return orderCode;
}

public void setOrderCode(String orderCode) {
    this.orderCode = orderCode;
}

public String getAttribute1() {
    return attribute4;
}

public void setAttribute1(String attribute1) {
    this.attribute1 = attribute1;
}

public String getAttribute2() {
    return attribute2;
}

public void setAttribute2(String attribute2) {
    this.attribute2 = attribute2;
}

public String getAttribute3() {
    return attribute3;
}

public void setAttribute3(String attribute3) {
    this.attribute3 = attribute3;
}

public String getAttribute4() {
    return attribute4;
}

public void setAttribute4(String attribute4) {
    this.attribute4 = attribute4;
}

public String getContractProvision() {
    return contractProvision;
}

public void setContractProvision(String contractProvision) {
    this.contractProvision = contractProvision;
}

}

后台方法:
@RequestMapping(params = {"method=insert"}, method = {org.springframework.web.bind.annotation.RequestMethod.POST}, consumes = {"application/x-www-form-urlencoded"}, produces = {"application/json"})

@ResponseBody
public Map insert(HttpServletRequest request, @Valid TransportVo vo){。。。。。}

为什么TransportVo 这个实体没有值呢?如果把后面这个实体参数删掉就可以请求跳转到后台。但问题是,我的项目中其他的页面也是这么写的就可以传值---前台传一个JSONDATA,后台方法有两个参数,页面发送请求之后,后台方法中这两个参数都有值。而我新建的页面却不行

我想知道是什么地方给这另外加的实体类赋值了呢?

1

7个回答

我想到一个可能的方向:浏览器会预判你的动作;也就是说浏览器会预先存储一些东西,默认帮你赋值了。建议查找方向是:浏览器预加载。
请参考。

0

新加的实体类代码贴一下

0
tjh434471446
JieHaoT 回复SugaryoTT: 加上注解应该能解析了
大约一年之前 回复
SugaryoTT
SugaryoTT 贴到里面了~
大约一年之前 回复

打断点debug呢,看看后台接收到的值是什么

0
SugaryoTT
SugaryoTT 如果后台我去掉了TransportVo这个参数,那么就可以传到后台,可以DEBUG。但是加了这个实体参数,就不可以了。问题是项目中别的页面也是这样,就可以传值
大约一年之前 回复

你传的是json,本质还是一个String字符串,后台就用String类型接受,用一个Bean(TransportVo )怎么接收得到?

0

传过来的本质是String. 可以通过工具来解析封装成实体类(有相关jar工具)。或设置拦截器直接解析。以后再出再这种问题就直接接受实体类就简单了

0

你检查下其他的地方的 params: jsonData, 这个**jsonData**也是你这样写的吗?

0

后台无jsonDateForDetail字段 后台不能少字段 少了是无法接收到数据的

0
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!

相似问题