java - SpringMVC Jackson Polymorphic Deserialisation with HTML Forms -


hi i'm using jackson polymorphic deserialization @jsontypeinfo , @jsonsubtypes annotations this:

@jsontypeinfo(use=jsontypeinfo.id.name,include=jsontypeinfo.as.property,property="type") @jsonsubtypes({         @type(value = customerfilecontent.class, name="filecontent"),         @type(value = customercontactcontent.class, name="contactcontent"),         @type(value = customertextcontent.class, name="textcontent"),         @type(value = customerwebcontent.class, name="webcontent") })  public class customercontent {     private int categoryid_;     private int contentid_;     private string contentname_;     private string contenttype_;     private int contentorder_;     private double contentversion_;     private int contentstatus_;     private int moveoldval_;     private int movenewval_;     protected finarappdatasource datasource;   @jsontypename("filecontent") public class customerfilecontent extends customercontent  {     private int filecontentid_;     private string filepath_;     private string filetype_; 

it works fine when send data client json object. when try send these datas html form (like in below code), doesn't cast base class type object(customercontent) concrete class type object(customerfilecontent).

<form action="<%= blobstoreservice.createuploadurl("/customercontentmain") %>" name="contentform" onsubmit="disablesubmitbutton()" method="post" enctype="multipart/form-data">     <table cellspacing="1" cellpadding="0">         <tr><td>İçerik İsmi :  </td> <td><input type="text" name="contentname" id="contentname" required/></td></tr>         <tr><td>İçerik dosyası : </td> <td><input type="file" name="filepath" required/></td></tr>          <br>     <tr>         <td><input type="hidden" id="categoryid" name="categoryid" value="${categoryid}"/>             <input type="hidden" id="contentstatus" name="contentstatus" value="<%= finarconstants.mode_insertval %>"/>             <input type="hidden" id="contenttype" name="contenttype" value="<%= finarconstants.content_type_file %>" />             <input type="hidden" id="filetype" name="filetype" value="pdf" />             <input type="hidden" id="contentid" name="contentid" value="-1"/>             <input type="hidden" id="moveoldval" name="moveoldval" value="-1"/>             <input type="hidden" id="movenewval" name="movenewval" value="-1"/>             <input type="hidden" id="type" name="type" value="filecontent" /></td>          <td><input type="submit" id="submitbutton" value="ekle...." /></td>     </tr>     </table> </form> 

and here spring-mvc receiving part

@requestmapping(value="/customercontentmain", method = requestmethod.post) public string getcustomercontentmainpage(@modelattribute("contentinput") customercontent contentinput) {     string result = "finarcustomerloginerror";     if (request.getsession().getattribute("customerid") == null)     {         result = "finar";     } else{          map<string, list<blobkey>> blobs = blobstoreservice.getuploads(request);         blobkey filepathkey  = blobs.get("filepath").get(0);           //finarcustomercontent content = contentinput.getcontent();         contentinput.setcontentfilepath(filepathkey.getkeystring());         customercontentcontroller contentcontroller = new customercontentcontroller(contentinput);         contentcontroller.setcontentdata();         result = contentcontroller.getcontentpage();     }             return result; } 

does know solution problem? or bug in jackson , should have use angular.js?

thanks tolga


Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -