请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

店铺类别和所属区域没有显示

$(function () {
    var initUrl='/o2o/shop/getshopinitinfo';
    var registerShopUrl='/o2o/shopadmin/registershop';
    alert(initUrl);
    getShopInitInfo();

    function getShopInitInfo() {
        $.getJSON(initUrl,function (data) {
            if(data.success){
                var tempHtml='';
                var tempAreaHtml='';
                data.shopCategoryList.map(function (item,index) {
                    tempHtml += '<option data-id="' + item.shopCategoryId
                        + '">' + item.shopCategoryName + '</option>';
                });
                data.areaList.map(function (item,index) {
                    tempAreaHtml += '<option data-id="' + item.areaId + '">'
                        + item.areaName + '</option>';
                });
                $('#shop-category').html(tempHtml);
                $('#area').html(tempAreaHtml);
            }
        });
        $('#submit').click(function () {
            var shop={};
            shop.shopName=$('#shop-name').val();
            shop.shopAddr=$('#shop-addr').val();
            shop.phone=$('#shop-phone').val();
            shop.shopDesc=$('#shop-desc').val();
            shop.shopCategory={}
            shop.shopCategory = {
                shopCategoryId : $('#shop-category').find('option').not(function() {
                    return !this.selected;
                }).data('id')};
            shop.area = {
                areaId : $('#area').find('option').not(function() {
                    return !this.selected;
                }).data('id')
            };
            var shopImg=$('#shop-img')[0].files[0];
            var formData=new FormData();
            formData.append('shopImg',shopImg);
            formData.append('shopStr',JSON.stringify(shop));
            $.ajax({
                url:registerShopUrl,
                type:'POST',
                data:formData,
                contentType:false,
                proceesData:false,
                cache:false,
                success:function (data) {
                    if (data.success){
                        $.toast('提交成功!');
                    }else {
                        $.toast('提交失败!'+data.errMsg);
                    }
                }
            });
        });
    }
})

以上是js代码

//img1.sycdn.imooc.com//szimg/5ab0fc140001af4f19201040.jpg

//img1.sycdn.imooc.com//szimg/5ab0fc15000147f619201040.jpg

https://img1.sycdn.imooc.com//szimg/5ab114a80001b91a19201048.jpg

看控制台信息的话貌似是get请求找不到一个具体的类吗?

缺乏看这信息的能力,请老师多指教。

在ShopManagementController类中的@Autowired标签有报错,但是不影响程序运行,经过测试可以用构造注入去掉报错//img1.sycdn.imooc.com//szimg/5ab0fcf70001f42603540137.jpg

//img1.sycdn.imooc.com//szimg/5ab10f150001486603040121.jpg

以下是编译器控制台在点击//img1.sycdn.imooc.com//szimg/5ab0fd880001f15c04940147.jpg后的提示信息

//img1.sycdn.imooc.com//szimg/5ab0fd690001cece12950735.jpg

shopCategoryDao层是没有问题的,通过测试//img1.sycdn.imooc.com//szimg/5ab0fe04000116b314870221.jpg

现在想不出问题出在哪,是service层还是Controller层?,看tomcat信息貌似是处在service层,但是却无法定位错误,请老师指示

正在回答

4回答

同学好,建议同学不要自己回复自己的问题,不然很难看到。

看到同学的问题还挺多,首先先来解决404这个错误,你可以看到common.js这个文件找不到,请先按照视频里把common.js这个文件引入工程对应目录再说,现在就是找不到它才报错的。而且验证码的部分,感觉同学是不是没有按照视频里的来,而是赋值粘贴来搞的,因为才第四章结果就出现了验证码?这样是不行的,会遇到越来越多的问题。请严格按照视频来,不然问题太多同学又解决不了的话只能跟着视频来,否则没法定位了

0 回复 有任何疑惑可以回复我~
  • 提问者 Jimblack #1
    老师,我是在不确定html代码是否打对了的情况下复制了老师的代码并修改。
    
    在我的记忆中貌似老师在本节没有讲到common.js啊 这个js文件是后面的内容吗
    回复 有任何疑惑可以回复我~ 2018-03-20 22:09:11
  • 提问者 Jimblack #2
    老师  我经过检查,发现common.js是我没有删除的原因,目前只有一个错误了,就是getshopinfo这个方法了。但是请问如何通过这个前端控制台知道是我js中的geishopinfo出错了还是ShopManagementController类中的geishopinfo方法出错了呢
    回复 有任何疑惑可以回复我~ 2018-03-20 22:16:53
  • 提问者 Jimblack #3
    老师,这句话是意思呢?
    message /o2o/shop/getshopinitinfo
    项目中只有一个shop实体类呀
    这里是指ShopManagementController中value=“getshopinfo”的那个geiShopInfo方法吗
    回复 有任何疑惑可以回复我~ 2018-03-20 22:24:40
提问者 Jimblack 2018-03-20 21:08:45

https://img1.sycdn.imooc.com//szimg/5ab107020001ca0911450112.jpg

排查了一会儿,难道是我js写错了? 验证过代码,感觉可能出错的地方就是https://img1.sycdn.imooc.com//szimg/5ab1073f0001f3a603420043.jpg这里。

我的项目结构和老师的不同,没有com.mooc    就直接o2o了 ,不过这是在项目根目录里的呀,加个绝对路径应该是没问题的,我稍后验证。 还有一个可能就是https://img1.sycdn.imooc.com//szimg/5ab107b80001b19205260051.jpghtml中的路径吗?但是这里的路径也应该没有问题的

0 回复 有任何疑惑可以回复我~
  • 提问者 Jimblack #1
    修改路径后没有效果,验证失败
    回复 有任何疑惑可以回复我~ 2018-03-20 21:10:02
提问者 Jimblack 2018-03-20 20:41:56
   <!-- 联系电话 text -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">联系电话</div>
                                <div class="item-input">
                                    <input type="text" id="shop-phone" placeholder="联系电话">
                                </div>
                            </div>
                        </div>
                    </li>
                    <!-- 缩略图 上传控件 -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">缩略图</div>
                                <div class="item-input">
                                    <input type="file" id="shop-img">
                                </div>
                            </div>
                        </div>
                    </li>
                    <!-- 店铺简介 textarea -->
                    <li class="align-top">
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">店铺简介</div>
                                <div class="item-input">
                                    <textarea id="shop-desc" placeholder="店铺简介"></textarea>
                                </div>
                            </div>
                        </div>
                    </li>
                    <!-- 验证码 ka -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">验证码</div>
                                <input type="text" id="j_captcha" placeholder="验证码">
                                <div class="item-input">
                                    <img id="captcha_img" alt="点击更换" title="点击更换"
                                         onclick="changeVerifyCode(this)" src="../Kaptcha" />
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <div class="content-block">
                <div class="row">
                    <div class="col-50">
                        <a href="/o2o/shopadmin/shopmanagement" class="button button-big button-fill button-danger">返回</a>
                    </div>
                    <div class="col-50">
                        <a href="#" class="button button-big button-fill button-success"
                           id="submit">提交</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>
<script type='text/javascript'
        src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
<script type='text/javascript'
        src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
<script type='text/javascript'
        src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
<script type='text/javascript' src='../resources/js/common/common.js'
        charset='utf-8'></script>
<script type='text/javascript'
        src='../resources/js/shop/shopoperation.js' charset='utf-8'></script>
</body>
</html>

以上是html代码,一次贴不完,分两次

0 回复 有任何疑惑可以回复我~
提问者 Jimblack 2018-03-20 20:41:12
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>SUI Mobile Demo</title>
    <meta name="description"
          content="MSUI: Build mobile apps with simple HTML, CSS, and JS components.">
    <meta name="author" content="阿里巴巴国际UED前端">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <link rel="shortcut icon" href="/favicon.ico">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">

    <!-- Google Web Fonts -->

    <link rel="stylesheet"
          href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
    <link rel="stylesheet"
          href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">

    <link rel="apple-touch-icon-precomposed"
          href="/assets/img/apple-touch-icon-114x114.png">

</head>
<body>
<div class="page-group">
    <div id="page-label-input" class="page">
        <header class="bar bar-nav">
            <a class="button button-link button-nav pull-left back"
               href="/demos/form"> <span class="icon icon-left"></span> 返回
            </a>
            <h1 class="title">商店信息</h1>
        </header>
        <div class="content">
            <div class="list-block">
                <ul>
                    <!-- Text inputs -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">商铺名称</div>
                                <div class="item-input">
                                    <input type="text" id="shop-name" placeholder="商铺名称">
                                </div>
                            </div>
                        </div>
                    </li>
                    <!-- 商铺分类 下拉列表 -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">商铺分类</div>
                                <div class="item-input">
                                    <select id="shop-category">
                                    </select>
                                </div>
                            </div>
                        </div>
                    </li>
                    <!-- 区域分类 下拉列表 -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">所属区域</div>
                                <div class="item-input">
                                    <select id="area">
                                    </select>
                                </div>
                            </div>
                        </div>
                    </li>
                    <!-- 详细地址 text -->
                    <li>
                        <div class="item-content">
                            <div class="item-inner">
                                <div class="item-title label">详细地址</div>
                                <div class="item-input">
                                    <input type="text" id="shop-addr" placeholder="详细地址">
                                </div>
                            </div>
                        </div>
                    </li>


0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信