HttpServletRequest kann Anforderungsorganisation nicht speichernJava

Java-Forum
Anonymous
 HttpServletRequest kann Anforderungsorganisation nicht speichern

Post by Anonymous »

Ich versuche, meine Springboot -Anwendung zu verbessern, um die Stapelverarbeitung zu unterstützen. Der folgende Code behandelt die eingehenden API -Aufrufe < /p>

Code: Select all

@Operation(summary = "OData service exposed by it.")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Service is running.",
content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = String.class))}),
@ApiResponse(responseCode = "500", description = "Internal server error.",
content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
schema = @Schema(implementation = ErrorDetails.class))})})
@RequestMapping(value = "**")
void process(HttpServletRequest request, HttpServletResponse response) throws IOException {
if (request.getInputStream().available() > 0) {
System.out.println("Input Stream data present");
}
}
< /code>
Ich führe meinen API -Anruf von Postman wie unten aus: < /p>
curl --location --request POST 'http://localhost:8084/api/v1/inv/$batch' \
--header 'Content-Type: multipart/mixed;boundary=abc123;' \
--data-raw '--abc123
Content-Type: application/http
Content-Transfer-Encoding: binary

GET http://localhost:8084/api/v1/inv/Port_Type HTTP/1.1

--abc123
Content-Type: application/http
Content-Transfer-Encoding: binary

GET http://localhost:8084/api/v1/inv/Device_Type HTTP/1.1

--abc123--
'
In meinem Java -Code, Request.getInputStream (). AUFEHLE () kehrt immer zurück. GetInputStream () wurde bereits für diese Anfrage aufgerufen.
Hier ist der aktualisierte Code:

Code: Select all

    public void process(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
BufferedReader reader = request.getReader();

}
Sieht so aus, als würde GetInputStream () schon vor dem Erreichen des Controllers

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post