spring-hateoas-ext/src/main/java/de/escalon/hypermedia/spring/xhtml/XhtmlResourceMessageConverter.java
private InputStream getBodyFromServletRequestParameters(HttpServletRequest request, String charset) throws
            IOException {

        ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
        Writer writer = new OutputStreamWriter(bos, charset);
        @SuppressWarnings("unchecked")
        Map<String, String[]> form = request.getParameterMap();
        for (Iterator<String> nameIterator = form.keySet()
                .iterator(); nameIterator.hasNext(); ) {
            String name = nameIterator.next();
            List<String> values = Arrays.asList(form.get(name));
            for (Iterator<String> valueIterator = values.iterator(); valueIterator.hasNext(); ) {
                String value = valueIterator.next();
                writer.write(URLEncoder.encode(name, charset));
                if (value != null) {
                    writer.write('=');
                    writer.write(URLEncoder.encode(value, charset));
                    if (valueIterator.hasNext()) {
                        writer.write('&');
                    }
                }
            }
            if (nameIterator.hasNext()) {
                writer.append('&');
            }
        }
        writer.flush();

        return new ByteArrayInputStream(bos.toByteArray());
    }
private InputStream getBodyFromServletRequestParameters(HttpServletRequest request, String charset) throws
            IOException {

        ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
        Writer writer = new OutputStreamWriter(bos, charset);
        @SuppressWarnings("unchecked")
        Map<String, String[]> form = request.getParameterMap();
        for (Iterator<String> nameIterator = form.keySet()
                .iterator(); nameIterator.hasNext(); ) {
            String name = nameIterator.next();
            List<String> values = Arrays.asList(form.get(name));
            for (Iterator<String> valueIterator = values.iterator(); valueIterator.hasNext(); ) {
                String value = valueIterator.next();
                writer.write(URLEncoder.encode(name, charset));
                if (value != null) {
                    writer.write('=');
                    writer.write(URLEncoder.encode(value, charset));
                    if (valueIterator.hasNext()) {
                        writer.write('&');
                    }
                }
            }
            if (nameIterator.hasNext()) {
                writer.append('&');
            }
        }
        writer.flush();

        return new ByteArrayInputStream(bos.toByteArray());
    }
private InputStream getBodyFromServletRequestParameters ( HttpServletRequest request , String charset ) throws IOException { ByteArrayOutputStream bos = new ByteArrayOutputStream ( 1024 ) ; Writer writer = new OutputStreamWriter ( bos , charset ) ; @ SuppressWarnings ( "unchecked" ) Map < String , String [ ] > form = request . getParameterMap ( ) ; for ( Iterator < String > nameIterator = form . keySet ( ) . iterator ( ) ; nameIterator . hasNext ( ) ; ) { String name = nameIterator . next ( ) ; List < String > values = Arrays . asList ( form . get ( name ) ) ; for ( Iterator < String > valueIterator = values . iterator ( ) ; valueIterator . hasNext ( ) ; ) { String value = valueIterator . next ( ) ; writer . write ( URLEncoder . encode ( name , charset ) ) ; if ( value != null ) { writer . write ( ' ' ) ; writer . write ( URLEncoder . encode ( value , charset ) ) ; if ( valueIterator . hasNext ( ) ) { writer . write ( ' ' ) ; } } } if ( nameIterator . hasNext ( ) ) { writer . append ( ' ' ) ; } } writer . flush ( ) ; return new ByteArrayInputStream ( bos . toByteArray ( ) ) ; }
From {@link ServletServerHttpRequest}: Use {@link javax.servlet.ServletRequest#getParameterMap()} to reconstruct
the body of a form 'POST' providing a predictable outcome as opposed to reading from the body, which can fail if
any other code has used ServletRequest to access a parameter thus causing the input stream to be "consumed".
From {