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= "f Orm-group "> <label for= "Name" class= "Control-label col-md-3" > Name:</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" > Infrastructure type:</label> <div class= "Co L-md-8 "> <select id=" type "name=" type "class=" Form-control "> <option value= ' > Please select the type of infrastructure </option> <option value= ' lookout tower ' > Watchtower </option> &L T;option value= ' Communication tower ' > Communication Tower </option> </select> </div> </div> <div class= "Form-group" > <label class= "Control-label col-md- 3 "> Accessories:</label> <div class=" col-md-8 "id=" Imgscontent "> </div> </div> <!-- Accessories--<div class= "Form-group" > <labelfor = "FileList" class= "Control-label col-md-3" > Attachment upload:</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> & lt;/div> </div> <div class= "Modal-footer" > <input class= "btn btn-success" type= "Submit" value= "Save"/> < Input class= "btn Btn-default" type= "reset" value= "reset"/> </div> </form>
Js
$ (function () {initable (); Filter (); $("#btn_search"). Click (function () {$ (' #mytab '). Bootstraptable (' Selectpage ', 1); }); $("#infoWindow"). On ("Submit", Function (e) {e.preventdefault (); var form=NewFormData (document.getElementById ("Infoform")); var URL=$ ("#modalTitle"). Text () = = "new"? 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 PublicMap<string,string> Create (@Valid Observatory Observatory, @RequestParam ("FileList") commonsmultipartfile[] files) {Map<String,String> maps=NewHashmap<string, string>(); Try { //img File UploadStringBuilder Path =NewStringBuilder (); 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 ():p ath.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); } returnmaps; }
Service
Public void saveobservatory (Observatory entity) { new coordinate (ENTITY.GETGISX (). Doublevalue (), Entity.getgisy (). Doublevalue ()); = Geometryfactory.createpoint (coord); = Geometryfactory.creategeometry (point); Geom.setsrid (2343); Entity.setgeom (GEOM); Observatorydao.save (entity); }
Hibernate saves spatial data to the spatial library