我已經得到了一大堆的angularJS,休息和實體的東西一起工作,以便能夠通過我的POSTGRES數據庫中的REST保存表單數據。JSON字符串到字節[] JSONParseException
但是,我決定嘗試與其中一個實體字段不同的東西,以便我可以在數據庫中存儲更長的文本位。我想用一個字段的實體如下:
@Column
private int age;
@Lob
@Column(length = 2147483647)
private byte[] otherNeeds;
現在,實體創建就好了。我基於JBoss Forge腳手架構建了我的REST接口。只要我將「otherNeeds」字段保留爲空,一切工作都正常,通過REST保存表單。
這裏是我的形式:
<input id="age" type="number" ng-model="primaryGuest.age"></input>
<input id="otherNeeds" type="text" ng-maxlength="2147483647" ng-model="primaryGuest.otherNeeds"></input>
所有這些數據是通過正確地傳遞到我的JavaScript對象AngularJS,當我點擊保存按鈕(),我可以看到POST請求,我們將向您給我的REST接口具有以下有效載荷:
{
otherNeeds: "jjjjjj"
age: "10"
}
然而,來自服務器的響應返回是一個例外:
Caused by: org.codehaus.jackson.JsonParseException: Failed to decode VALUE_STRING as base64 (MIME-NO-LINEFEEDS): Illegal character '"' (code 0x22) in base64 content
at [Source: [email protected]; line: 1, column: 67]
at org.codehaus.jackson.JsonParser._constructError(JsonParser.java:1433) [jackson-core-asl-1.9.9-redhat-2.jar:1.9.9-redhat-2]
at org.codehaus.jackson.impl.Utf8StreamParser.getBinaryValue(Utf8StreamParser.java:402) [jackson-core-asl-1.9.9-redhat-2.jar:1.9.9-redhat-2]
at org.codehaus.jackson.map.deser.std.PrimitiveArrayDeserializers$ByteDeser.deserialize(PrimitiveArrayDeserializers.java:289)
at org.codehaus.jackson.map.deser.std.PrimitiveArrayDeserializers$ByteDeser.deserialize(PrimitiveArrayDeserializers.java:275)
at org.codehaus.jackson.map.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:299)
at org.codehaus.jackson.map.deser.SettableBeanProperty$MethodProperty.deserializeAndSet(SettableBeanProperty.java:414)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:697)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1315)
at org.codehaus.jackson.jaxrs.JacksonJsonProvider.readFrom(JacksonJsonProvider.java:419)
at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:105) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.read(GZIPDecodingInterceptor.java:63) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
at org.jboss.resteasy.core.interception.MessageBodyReaderContextImpl.proceed(MessageBodyReaderContextImpl.java:108) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
at org.jboss.resteasy.core.MessageBodyParameterInjector.inject(MessageBodyParameterInjector.java:169) [resteasy-jaxrs-2.3.6.Final-redhat-1.jar:2.3.6.Final-redhat-1]
... 33 more
所以,我不知道如何處理這種情況,以便將我的對象轉換爲byte []格式可接受的內容。我可以選擇回到標準的「字符串」字段,但我希望能夠爲用戶提供他們可以提供的「無限量」文本。
任何建議將不勝感激。