1,先说一下自己的问题,用postman测试数据
<html>
<head>
<title>Apache Tomcat/7.0.59 - Error report</title>
<style>
<!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}-->
</style>
</head>
<body>
<h1>HTTP Status 415 - </h1>
<HR size="1" noshade="noshade">
<p>
<b>type</b> Status report
</p>
<p>
<b>message</b>
<u></u>
</p>
<p>
<b>description</b>
<u>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.</u>
</p>
<HR size="1" noshade="noshade">
<h3>Apache Tomcat/7.0.59</h3>
</body>
</html>
报这个问题:
改成
就可以了
紧接着报
<html> <head> <title>Apache Tomcat/7.0.59 - Error report</title> <style> <!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--> </style> </head> <body> <h1>HTTP Status 400 - </h1> <HR size="1" noshade="noshade"> <p> <b>type</b> Status report </p> <p> <b>message</b> <u></u> </p> <p> <b>description</b> <u>The request sent by the client was syntactically incorrect.</u> </p> <HR size="1" noshade="noshade"> <h3>Apache Tomcat/7.0.59</h3> </body> </html>
主要原因就是端上和Springmvc的对接的参数不一致导致的。
端上的json数据是:
{ "reqVoList": [ { "cmmdtyName": "伊莱克斯冰箱EBM2500WA-R", "comingStockNum": "4", "createTime": "2019-01-18", "operator": "7017963441", "orderItemNo": "A100101462301", "orderNo": "A1001014623", "supplierCode": "0000000000" }, { "cmmdtyName": "TCL冰箱BCD-211KD3闪白银", "comingStockNum": "1", "createTime": "2019-01-18", "operator": "7017963441", "orderItemNo": "A100101462302", "orderNo": "A1001014623", "supplierCode": "0000000000" } ] }
后台接受的代码
@ResponseBody
@RequestMapping(value = "/saveBathInStock", method = RequestMethod.POST)
public ResponseVO<ConfirmWebPurchasInRspVO> saveBathInStock(@User LoginUser user, @RequestBody List<SaveInStockReqVo> reqList)
SaveInStockReqVo:
package com.suning.srcskf.vo.stock; import java.io.Serializable; public class SaveInStockReqVo implements Serializable { private static final long serialVersionUID = -2504062686085615430L; /** * 订单号 */ private String orderNo; /** * 订单行号 */ private String orderItemNo; private String storeStockCount; /** * 下单时间 */ private String purchaseTime; /** * 操作人 */ private String operateUser; /** * 门店编码 */ private String storeCode; /** *商编 */ private String cmmdtyCode; /** * 商品名称 */ private String cmmdtyName; private String barCode; private String updateUser; /** * 供应商:苏宁自营 */ private String supplier; /** * 供应商编码 */ private String supplierCode; /** * web端下单时间 * @return */ private String createTime; /** * web端操作人 * @return */ private String operator; /** * web入库数量 * @return */ private String comingStockNum; public String getComingStockNum() { return comingStockNum; } public void setComingStockNum(String comingStockNum) { this.comingStockNum = comingStockNum; } public String getOperator() { return operator; } public void setOperator(String operator) { this.operator = operator; } public String getCreateTime() { return createTime; } public void setCreateTime(String createTime) { this.createTime = createTime; } public String getSupplier() { return supplier; } public void setSupplier(String supplier) { this.supplier = supplier; } public String getSupplierCode() { return supplierCode; } public void setSupplierCode(String supplierCode) { this.supplierCode = supplierCode; } public String getPurchaseTime() { return purchaseTime; } public void setPurchaseTime(String purchaseTime) { this.purchaseTime = purchaseTime; } public String getOperateUser() { return operateUser; } public void setOperateUser(String operateUser) { this.operateUser = operateUser; } public String getOrderNo() { return orderNo; } public void setOrderNo(String orderNo) { this.orderNo = orderNo; } public String getOrderItemNo() { return orderItemNo; } public void setOrderItemNo(String orderItemNo) { this.orderItemNo = orderItemNo; } public String getStoreStockCount() { return storeStockCount; } public String getCmmdtyName() { return cmmdtyName; } public void setCmmdtyName(String cmmdtyName) { this.cmmdtyName = cmmdtyName; } public void setStoreStockCount(String storeStockCount) { this.storeStockCount = storeStockCount; } public String getStoreCode() { return storeCode; } public void setStoreCode(String storeCode) { this.storeCode = storeCode; } public String getCmmdtyCode() { return cmmdtyCode; } public void setCmmdtyCode(String cmmdtyCode) { this.cmmdtyCode = cmmdtyCode; } public String getBarCode() { return barCode; } public void setBarCode(String barCode) { this.barCode = barCode; } public String getUpdateUser() { return updateUser; } public void setUpdateUser(String updateUser) { this.updateUser = updateUser; } }
原因就是端上的json数据和vo不一致导致的
修改方法一:
修改json数据
[ { "cmmdtyName": "伊莱克斯冰箱EBM2500WA-R", "comingStockNum": "4", "createTime": "2019-01-18", "operator": "7017963441", "orderItemNo": "A100101462301", "orderNo": "A1001014623", "supplierCode": "0000000000" }, { "cmmdtyName": "TCL冰箱BCD-211KD3闪白银", "comingStockNum": "1", "createTime": "2019-01-18", "operator": "7017963441", "orderItemNo": "A100101462302", "orderNo": "A1001014623", "supplierCode": "0000000000" } ]
方式二,修改java代码
在创建一个新类:
比如A
package com.suning.srcskf.vo.stock; import java.util.List; public class A { List<SaveInStockReqVo> reqVoList; public List<SaveInStockReqVo> getReqVoList() { return reqVoList; } public void setReqVoList(List<SaveInStockReqVo> reqVoList) { this.reqVoList = reqVoList; } }
控制层改成这样
public ResponseVO<ConfirmWebPurchasInRspVO> saveBathInStock(@User LoginUser user, @RequestBody A a)
原文地址:https://www.cnblogs.com/qingruihappy/p/10340241.html