画像をディスクに保存したいpngデータのjson文字列を送信しています。
jsonInputString= URLDecoder.decode( inputString, "UTF-8" );
jsonInputString= jsonInputString.substring(inputStrjsonInputStringing.indexOf(",")+1);
byte[] decodedBytes = DatatypeConverter.parseBase64Binary(jsonInputString);
サニタイズ後のjsonInputString:
iVBORw0KGgoAAAANSUhEUgAAAlgAAABkCAYAAABaQU4jAAAOUUlEQVR4Xu3dgZUMywIG4BEBIkAEiAARWBEggiUCRIAIEAEiQARsBIgAEXjv7/NqX5kzs9szXd3Ts/P1OXtcV3d191fl9n+rqqsv/f3vtrARIECAAAECBAg0E7gkYDWzVBABAgQIECBAoBMQsDQEAgQIECBAgEBjAQGrMajiCBAgQIAAAQICljZAgAABAgQIEGgsIGA1BlUcAQIECBAgQEDA0gYIECBAgAABAo0FBKzGoIojQIAAAQIECAhY2gABAgQIECBAoLGAgNUYVHEECBAgQIAAAQFLGyBAgAABAgQINBYQsBqDKo4AAQIECBAgIGBpAwQIECBAgACBxgICVmNQxREgQIAAAQIEBCxtgAABAgQIECDQWEDAagyqOAIECBAgQICAgKUNECBAgAABAgQaCwhYjUEVR4AAAQIECBAQsLQBAgQIECBAgEBjAQGrMajiCBAgQIAAAQICljZAgAABAgQIEGgsIGA1Bt2kuB8/fix+/vzZHZJ/vnbt2uLu3bubFGFfAgQIECBAYIYCAtaOKuX169eL58+fL37//v3PFTx58mTx7NmzxZUrV3Z0ZU5LgAABAgQIDBUQsIYKbnh8eqoeP368+Pz5c3fkzZs3T8PUly9fun9369atxadPn4SsDW3tToAAAQIE5iIgYE1YEwlVDx486HqtLl++vHj79u3i6Ojo9Aq+ffu2ePTo0eLk5GRxfHy8ePXq1YRX51QECBAgQIBAKwEBq5XkOeUkTKXnKtv9+/e7cLVqGDAh6/bt291+79+//yeATXSpTkOAAAECBAgMFBCwBgL2OTzBKoEqW+ZXZe7VWVt6rp4+fdoFsO/fvxsq7INsHwIECBAgMCMBAWvEyshQYIYEy3yrN2/edEOAfba8TZg5WS9fvlx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nu0XkIEOgvIGD1t7LnBALpgcpP/amZ+rTltfoyObn+s/L9wASzocOME9yqUxyAQN/QZT7XATQGt3hwAgLWwVX5ftxwAlSGCjN3al3YSqAqD6ayWOd+3J2rPGSBMp+rzOk6661FvVyH3FLc+74LCFj7XoMHdv2l56pe8fzACNzuBRPoM59rTt/vvGD8bofAaAIC1mi0CiZAgMB2AnUvV3q68j8U2yyaut3ZHUWAQAsBAauFojIIECBAgAABApWAgKU5ECBAgAABAgQaCwhYjUEVR4AAAQIECBAQsLQBAgQIECBAgEBjAQGrMajiCBAgQIAAAQICljZAgAABAgQIEGgsIGA1BlUcAQIECBAgQEDA0gYIECBAgAABAo0FBKzGoIojQIAAAQIECAhY2gABAgQIECBAoLGAgNUYVHEECBAgQIAAAQFLGyBAgAABAgQINBYQsBqDKo4AAQIECBAgIGBpAwQIECBAgACBxgICVmNQxREgQIAAAQIEBCxtgAABAgQIECDQWEDAagyqOAIECBAgQICAgKUNECBAgAABAgQaCwhYjUEVR4AAAQIECBAQsLQBAgQIECBAgEBjAQGrMajiCBAgQIAAAQICljZAgAABAgQIEGgsIGA1BlUcAQIECBAgQEDA0gYIECBAgAABAo0FBKzGoIojQIAAAQIECAhY2gABAgQIECBAoLGAgNUYVHEECBAgQIAAgf8A8F+SPj1gu94AAAAASUVORK5CYII=
結果は
with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause
java.lang.NullPointerException
at javax.xml.bind.DatatypeConverter.parseBase64Binary(DatatypeConverter.java:296)
それはランダムに動作しますが、ランダムに動作させるために時間を費やしてきました.
Web クライアントからの文字列はそのまま表示されます
jsonInputString = ....toDataURL('image/png');
jsonInputString = encodeURIComponent(jsonInputString );
console.log(jsonInputString );
現在のコードが機能しない理由を理解するのに役立つ助けをいただければ幸いです。
更新: JDK 1.6 Eclipse indigo