Fix using system default charset in view rendering

Prior to this commit, FreeMarkerView used the system default charset to
render. This commit switches this by defaulting to UTF-8, if no charset
is specified in the content type.

 - Add contentType parameter to AbstractView.renderInternal, used to
 determine the charset contained therein
 - Adds a defaultCharset property to AbstractView and
 ViewResolverSupport.
This commit is contained in:
Arjen Poutsma
2016-09-05 12:31:00 +02:00
parent a746c3c54e
commit 5f941c1dd1
5 changed files with 68 additions and 8 deletions

View File

@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.reactive.result.view;
import java.util.Locale;
@@ -22,6 +23,7 @@ import org.junit.Test;
import reactor.core.publisher.Mono;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.http.MediaType;
import org.springframework.web.server.ServerWebExchange;
import static org.junit.Assert.assertNotNull;
@@ -61,7 +63,8 @@ public class UrlBasedViewResolverTests {
}
@Override
protected Mono<Void> renderInternal(Map<String, Object> attributes, ServerWebExchange exchange) {
protected Mono<Void> renderInternal(Map<String, Object> attributes, MediaType contentType,
ServerWebExchange exchange) {
return Mono.empty();
}
}