亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

創建商品一直報錯404

https://img1.sycdn.imooc.com//5cbadf23000133ef06780575.jpg

https://img1.sycdn.imooc.com//5cbadf230001bb9410720336.jpg

這是我的前端代碼

<html>
<head>
<meta?charset="UTF-8">
????<link?href="static/assets/global/plugins/bootstrap/css/bootstrap.min.css"?style="stylesheet"?type="text/css"/>
????<link?href="static/assets/global/css/components.css"?rel="stylesheet"?type="text/css"/>
????<link?href="static/assets/admin/pages/css/login.css"?rel="stylesheet"?type="text/css"/>
????<script?src="static/assets/global/plugins/jquery-1.11.0.min.js"?type="text/javascript"></script>
</head>

<body?class="login">
????<div?class="content">
????????<h3?class="form-title">創建商品</h3>
????????<div?class="form-group">
????????????<label?class="control-label">商品名</label>
????????????<div>
????????????????<input?class="form-control"?type="text"?name="title"?id="title"/>
????????????</div>
????????</div>
??????<div?class="form-group">
????????????<label?class="control-label">商品描述</label>
????????????<div>
????????????????<input?class="form-control"?type="text"?name="description"?id="description"/>
????????????</div>
????????</div>
??????<div?class="form-group">
????????????<label?class="control-label">價格</label>
????????????<div>
????????????????<input?class="form-control"?type="text"?name="price"?id="price"/>
????????????</div>
????????</div>
??????<div?class="form-group">
????????????<label?class="control-label">圖片</label>
????????????<div>
????????????????<input?class="form-control"?type="text"?name="imgUrl"?id="imgUrl"/>
????????????</div>
????????</div>
??????<div?class="form-group">
????????????<label?class="control-label">庫存</label>
????????????<div>
????????????????<input?class="form-control"?type="text"?name="stock"?id="stock"/>
????????????</div>
????????</div>

????????<div?class="form-actions">
????????????<button?class="btn?blue"?id="create"?type="submit">
????????????????提交創建
????????????</button>
????????</div>
????</div>
</body>
<script>
????jQuery(document).ready(function?()?{

????????$("#create").on("click",function(){
????????????var?title?=?$("#title").val();
????????????var?description?=?$("#description").val();
????????????var?price?=?$("#price").val();
????????????var?imgUrl?=?$("#imgUrl").val();
????????????var?stock?=?$("#stock").val();

????????????if(title?==?null?||?title?==""){
????????????????alert("商品名不能為空");
????????????????return?false;
????????????}
?????????if(description?==?null?||?description?==""){
????????????????alert("描述不能為空");
????????????????return?false;
????????????}
?????????if(imgUrl?==?null?||?imgUrl?==""){
????????????????alert("圖片鏈接不能為空");
????????????????return?false;
????????????}
?????????if(stock?==?null?||?stock?==""){
????????????????alert("庫存不能為空");
????????????????return?false;
????????????}
????????????$.ajax({
????????????????type:"POST",
????????????????datatype:'json',
????????????????contendType:"application/x-www-form-urlencoded",
????????????????url:"http://localhost:8090/user/create",
????????????????data:JSON.stringify({
???????????????"title":title,
???????????????"description":description,
???????????????"price":price,
???????????????"imgUrl":imgUrl,
???????????????"stock":stock
????????????????}),
????????????xhrFields:{withCredentials:true},
????????????????success:function?(data)?{
????????????????????if(data.status?==??"success"){
????????????????????????alert("創建成功");
????????????????????}
????????????????????else{
????????????????????????alert("創建失敗1,原因為"+data.data.errMsg)
????????????????????}
????????????????},
????????????????error:function?(data)?{
????????????????????alert("創建失敗2,原因為"+data.responseText);??????????????????
????????????????}
????????????})
????????})
????????return?false;
????});
</script>


</html>

犯了很蠢的錯誤,鏈接寫錯了,應該是localhost:8090/item/create,我給寫成了localhost:8090/user/create

簡直蠢驢?。?br />

正在回答

1 回答

新手日常-------

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

創建商品一直報錯404

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號