• hibernate 保存空间数据到空间库


    jsp

    <form class="form-horizontal" id="infoForm">
                                <div class="modal-body">
                                    <div class="panel-body">
                                        <div class="row">
                                            <input type="hidden" name="gid"  />
                                            <div class="form-group">
                                                <label for="name" class="control-label col-md-3">名称:</label>
                                                <div class="col-md-8">
                                                    <input type="text" id="name" name="name" class="form-control "  required/>
                                                </div>
                                                <div class="col-md-1">
                                                    <span style="color:red;text-align:center">*</span>
                                                </div>
                                            </div>
                                           
                                            <div class="form-group">
                                                <label for="type" class="control-label col-md-3">基建类型:</label>
                                                <div class="col-md-8">
                                                    <select id="type" name="type" class="form-control " >
                                                        <option value=''>请选择基建类型</option>
                                                        <option value='瞭望塔' >瞭望塔</option>
                                                        <option value='通讯塔'>通讯塔</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group" >
                                                <label class="control-label col-md-3">附件:</label>
                                                <div class="col-md-8" id="imgsContent">
                                                </div>
                                            </div>
                                            <!-- 附件 -->
                                            <div class="form-group">
                                                <label for="fileList" class="control-label col-md-3">附件上传:</label>
                                                <div class="col-md-8">
                                                    <input type="file" accept="image/*"  multiple="multiple" id="fileList" name="fileList"  class="form-control " />
                                                </div>
                                            </div>
                                            <input type="hidden" id="imgFile" name="imgPath" class="form-control "/>
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <input class="btn btn-success" type="submit" value="保 存" />
                                    <input class="btn btn-default" type="reset" value="重 置" />
                                </div>
                            </form>

    js

    $(function(){
                iniTable();
                filter();
                $("#btn_search").click(function(){
                    $('#mytab').bootstrapTable('selectPage',1);
                });
                $("#infoWindow").on("submit",function(e){
                    e.preventDefault();
                    var form = new FormData(document.getElementById("infoForm"));
                    var url=$("#modalTitle").text()=="新增"?localhostPaht+ctx+'/resource/observatory/create':localhostPaht+ctx+'/resource/observatory/update';
                    $.ajax({
                        type: "post",
                        url: url,
                        data: form,
                        dataType: "json",
                        contentType: false,
                        processData: false,
                        success: function(response){
                            $modal.modal('hide');
                            alert(response.msg);
                            $('#mytab').bootstrapTable('refresh');
                        }
                    });
                });
            });

    controller

    @RequestMapping(value = "create", method = RequestMethod.POST)
        @ResponseBody
        public Map<String,String> create(@Valid Observatory Observatory, @RequestParam("fileList") CommonsMultipartFile[] files) {
            Map<String,String> maps=new HashMap<String, String>();
            try {
                //img文件上传
                StringBuilder path = new StringBuilder();
                for (CommonsMultipartFile file : files) {
                    String url = FtpSftpUtil.fileToFtp(file,folder);
                    if (StringUtils.isNoneBlank(url)) {
                        path.append(url).append(";");
                    }
                }
                String imgPath=Observatory.getImgPath();
                imgPath=StringUtils.isNoneBlank(Observatory.getImgPath())&&!"null".equals(Observatory.getImgPath())?Observatory.getImgPath()+path.toString():path.toString();
                Observatory.setImgPath(imgPath);
                observatoryService.saveObservatory(Observatory);
                maps.put("msg", MESSAGE_CREATE_SUCCESS);
            } catch (Exception e) {
                LoggerUtil.error(e);
                maps.put("msg", MESSAGE_CREATE_FAIL);
            }
            return maps;
        }

    service

    public void saveObservatory(Observatory entity) {
            Coordinate coord = new Coordinate(entity.getGisx().doubleValue(), entity.getGisy().doubleValue());
            Point point = geometryFactory.createPoint(coord);
            Geometry geom = geometryFactory.createGeometry(point);
            geom.setSRID(2343);
            entity.setGeom(geom);
            observatoryDao.save(entity);
        }
  • 相关阅读:
    【WebService】IIS下部署WebService出现“请求格式无法识别”
    SqlCacheDependency特性
    Frame框架在Html中的应用详解
    一个不错的css——之三行三列等高格局.

    人才战争的书
    2003年三亚游,诸多恶评再一次浮出水面(同事原创)
    转摘记录农民伯伯2011年看的东西
    Office 2010 中打开多个Excel文件只能在同一窗口中显示的问题
    一个50G大小的outlook2010 PST文件
  • 原文地址:https://www.cnblogs.com/73tong/p/8387163.html
Copyright © 2020-2023  润新知