ssm项目报400错误

1.

 <!--商品信息-->
        <div class="row">
            <div class="col-md-3  col-md-offset-1" style="text-align: center;padding: 15px;">
            
            	<input type="hidden" value="${commodityinfoXiangqingye.id}" id="commcityInfoid">
            
                <div style="border: 1px solid #28a4c9;padding: 20px;">
                    <img src="${commodityinfoXiangqingye.imgUrl}" class="commodityImg" id="commcityInfoImg">
                </div>
                <!-- <div style="display: flex;flex-direction: row; justify-content: center;align-items: center;width: 100%;">
                    <img src="img/CR430.png" style="width: 40px;height: 60px;margin: 5px 10px 5px 10px;">
                    <img src="img/CR430.png" style="width: 40px;height: 60px;margin: 5px 10px 5px 10px;">
                    <img src="img/CR430.png" style="width: 40px;height: 60px;margin: 5px 10px 5px 10px;">
                    <img src="img/CR430.png" style="width: 40px;height: 60px;margin: 5px 10px 5px 10px;">
                </div> -->
            </div>
            <div class="col-md-7 col-md-offset-1">
                <div class="row">
                    <div class="col-md-12" style="padding: 10px;">
                        <span style="font-size: 20px;font-weight: bold;padding-left: 15px;" id="commcityInfoName">
                        	${commodityinfoXiangqingye.commodity_name}
                        </span>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-1" style="padding: 10px;">
                        <span >价格</span>
                    </div>
                    <div class="col-md-9" style="padding: 10px;">
                        <span id="commcityInfoPrice">¥${commodityinfoXiangqingye.sell_price}</span>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-1" style="padding: 10px;">
                        <span >数量</span>
                    </div>
                    <div class="col-md-9" style="padding: 10px;">
                        <input type="number" value="1" style="width: 50px;margin-right: 15px;" id="commcityInfoNum">
                        件
                        <span style="margin-left: 20px;">库存:</span>
						${commodityinfoXiangqingye.stock}
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-1" style="padding: 10px;">
                        <span >送至</span>
                    </div>
                    <div class="col-md-3" style="padding: 10px;">
                        <select>
                            <option>山东省济南市槐荫区日照路</option>
                            <option>山东省济南市槐荫区日照路</option>
                            <option>山东省济南市槐荫区日照路</option>
                        </select>
                    </div>
                    <div class="col-md-4" style="display: table-cell;vertical-align: middle;text-align: center;">
                         <span class="text" style="padding-left: 30px;">
                                24小时送达 免运费
                         </span>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-4 text-right" style="padding: 10px;">
                        <a class="btn btn-danger" style="font-size: 15px;" onclick="addchat()">加入购物车</a>
                    </div>
                    <div class="col-md-4 text-left" style="padding: 10px;">
                        <a class="btn btn-danger"  style="font-size: 15px;">立即购买</a>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-6 text-right" style="padding: 10px;">
                        <div class="text-left" style="margin-top: 5px;margin-bottom: 5px;">
                            <span>支付方式</span>&nbsp;&nbsp;&nbsp;&nbsp;
                            <span>支付宝</span>&nbsp;
                            <span>银行卡</span>
                        </div>
                        <div  class="text-left" style="margin-top: 5px;margin-bottom: 5px;">
                            <span>收藏宝贝</span>
                        </div>
                    </div>
                </div>
            </div>
        </div>

2.

<script type="text/javascript">
	//获取物品信息
	function addchat(){
		    
		 var commcityInfoid=$("#commcityInfoid").val();
		 var commcityInfoImg=$("#commcityInfoImg").attr('src');
		 var commcityInfoName=$("#commcityInfoName").text();
		 var commcityInfoPrice=$("#commcityInfoPrice").text();
		 var commcityInfoNum=$("#commcityInfoNum").val();
		 $.ajax({
			    url : "${pageContext.request.contextPath}/addMyChat",
				type : "POST",
				data :JSON.stringify(
					{
						id:commcityInfoid,
						commodityName:commcityInfoName,
						commodityImg:commcityInfoImg,
						price:commcityInfoPrice,
						num:commcityInfoNum
					}
				),
				contentType : "application/json;charset=UTF-8",
				dataType : "json",
				success : function(data){
					window.alert(data);
				}
			});
	}
</script>

3.

public String addMyChat(
			@RequestBody myChat mychat,
			HttpServletRequest request,
			HttpServletResponse response,
			HttpSession session
			){}

4.

Request URL: http://localhost:8080/shop365/addMyChat
Request Method: POST
Status Code: 400 Bad Request
Remote Address: 127.0.0.1:8080
Referrer Policy: no-referrer-when-downgrade

 

原因:由于传输的参数值又空格,向后台传的值的不对报400错误,所以报400错误

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

飞飞翼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值