Wizzercn / NutzWk

WK系列开发框架-V1至V5 Java开源企业级开发框架(单应用/微服务/分布式)
https://budwk.com
Apache License 2.0
1.62k stars 637 forks source link

使用代码生成器后,进入修改页面时报页面未找到属性错误,debug时对象已经查询出来,返回给页面时报错 #89

Closed tian1iang closed 7 years ago

tian1iang commented 7 years ago

@At("/edit/?") @Ok("beetl:/platform/cms/test/edit.html") @RequiresPermissions("platform.cms.test") public void edit(String id,HttpServletRequest req) { req.setAttribute("obj", cmsTestService.fetch(id)); 这是自动生成的 报未找到属性(ATTRIBUTE_NOT_FOUND):id 位于15行 资源:/platform/cms/number/edit.html这个错,其他增删查没错,我没发现代码有问题

wendal commented 7 years ago

没有id属性?

tian1iang commented 7 years ago

有的,所有属性都会找不到,但是查出来的对象是正常的

wendal commented 7 years ago

整个edit.html 贴一下看看

tian1iang commented 7 years ago
<%
layout("/layouts/platform.html"){
%>
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/platform/cms/test" id="goBack" data-pjax><i class="ti-angle-left"></i>${msg['globals.button.back']}</a>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="editForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
                  action="${base}/platform/cms/test/editDo" method="post">
                <input name="id" type="hidden" value="${obj.id}">
                <div class="row mb10">
                    <div class="col-lg-12">
                        <div class="form-group">
                            <label for="number" class="col-sm-2 control-label">${msg['cms.test.column.number']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="number" class="form-control" name="number" data-parsley-required="true"
                                       placeholder="${msg['cms.test.column.number']}" value="${obj.number}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="numberType" class="col-sm-2 control-label">${msg['cms.test.column.numberType']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="numberType" class="form-control" name="numberType" data-parsley-required="true"
                                       placeholder="${msg['cms.test.column.numberType']}" value="${obj.numberType}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="city" class="col-sm-2 control-label">${msg['cms.test.column.city']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="city" class="form-control" name="city" data-parsley-required="true"
                                       placeholder="${msg['cms.test.column.city']}" value="${obj.city}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="district" class="col-sm-2 control-label">${msg['cms.test.column.district']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="district" class="form-control" name="district" data-parsley-required="true"
                                       placeholder="${msg['cms.test.column.district']}" value="${obj.district}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="state" class="col-sm-2 control-label">${msg['cms.test.column.state']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="state" class="form-control" name="state" data-parsley-required="true"
                                       placeholder="${msg['cms.test.column.state']}" value="${obj.state}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="minimum" class="col-sm-2 control-label">${msg['cms.test.column.minimum']}</label>
                            <div class="col-sm-8">
                                <input type="text" id="minimum" class="form-control" name="minimum" data-parsley-required="true"
                                       placeholder="${msg['cms.test.column.minimum']}" value="${obj.minimum}" >
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-3"></div>
                <div class="col-lg-6">
                    <div class="form-group text-center">
                        <label></label>

                        <div>
                            <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="${msg['globals.button.submit.tip']}">${msg['globals.button.submit']}</button>
                        </div>
                    </div>
                </div>
            </form>
        </section>

    </div>
</div>
<script language="JavaScript">
    $(document).ready(function () {
        $('#editForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    setTimeout(function () {
                        $("#goBack").trigger("click");
                    }, 1000);
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });
    });
</script>
<%}%>
wendal commented 7 years ago

这一行报错??

<input name="id" type="hidden" value="${obj.id}">
tian1iang commented 7 years ago

wendal commented 7 years ago

edit这个入口方法也贴一下

tian1iang commented 7 years ago

@at("/edit/?") @ok("beetl:/platform/cms/test/edit.html") @requirespermissions("platform.cms.test") public void edit(String id,HttpServletRequest req) { req.setAttribute("obj", cmsTestService.fetch(id));

wendal commented 7 years ago

完整代码

wendal commented 7 years ago

原因是啥?