Require Jackson 2.6+, FreeMarker 2.3.21+, XStream 1.4.5+
Issue: SPR-13062
This commit is contained in:
@@ -42,6 +42,7 @@ import freemarker.ext.servlet.HttpRequestParametersHashModel;
|
||||
import freemarker.ext.servlet.HttpSessionHashModel;
|
||||
import freemarker.ext.servlet.ServletContextHashModel;
|
||||
import freemarker.template.Configuration;
|
||||
import freemarker.template.DefaultObjectWrapperBuilder;
|
||||
import freemarker.template.ObjectWrapper;
|
||||
import freemarker.template.SimpleHash;
|
||||
import freemarker.template.Template;
|
||||
@@ -186,10 +187,10 @@ public class FreeMarkerView extends AbstractTemplateView {
|
||||
* {@link ObjectWrapper#DEFAULT_WRAPPER default wrapper} if none specified.
|
||||
* @see freemarker.template.Configuration#getObjectWrapper()
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
protected ObjectWrapper getObjectWrapper() {
|
||||
ObjectWrapper ow = getConfiguration().getObjectWrapper();
|
||||
return (ow != null ? ow : ObjectWrapper.DEFAULT_WRAPPER);
|
||||
return (ow != null ? ow :
|
||||
new DefaultObjectWrapperBuilder(Configuration.DEFAULT_INCOMPATIBLE_IMPROVEMENTS).build());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@ import org.springframework.web.servlet.view.AbstractView;
|
||||
* Abstract base class for Jackson based and content type independent
|
||||
* {@link AbstractView} implementations.
|
||||
*
|
||||
* <p>Compatible with Jackson 2.1 and higher.
|
||||
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
* @author Arjen Poutsma
|
||||
@@ -122,12 +122,6 @@ public abstract class AbstractJackson2View extends AbstractView {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the attribute in the model that should be rendered by this view.
|
||||
* When set, all other model attributes will be ignored.
|
||||
*/
|
||||
public abstract void setModelKey(String modelKey);
|
||||
|
||||
/**
|
||||
* Disables caching of the generated JSON.
|
||||
* <p>Default is {@code true}, which will prevent the client from caching the generated JSON.
|
||||
@@ -187,23 +181,13 @@ public abstract class AbstractJackson2View extends AbstractView {
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter out undesired attributes from the given model.
|
||||
* The return value can be either another {@link Map} or a single value object.
|
||||
* @param model the model, as passed on to {@link #renderMergedOutputModel}
|
||||
* @return the value to be rendered
|
||||
*/
|
||||
protected abstract Object filterModel(Map<String, Object> model);
|
||||
|
||||
/**
|
||||
* Write the actual JSON content to the stream.
|
||||
* @param stream the output stream to use
|
||||
* @param object the value to be rendered, as returned from {@link #filterModel}
|
||||
* @throws IOException if writing failed
|
||||
*/
|
||||
protected void writeContent(OutputStream stream, Object object)
|
||||
throws IOException {
|
||||
|
||||
protected void writeContent(OutputStream stream, Object object) throws IOException {
|
||||
JsonGenerator generator = this.objectMapper.getFactory().createGenerator(stream, this.encoding);
|
||||
|
||||
writePrefix(generator, object);
|
||||
@@ -230,13 +214,27 @@ public abstract class AbstractJackson2View extends AbstractView {
|
||||
generator.flush();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the attribute in the model that should be rendered by this view.
|
||||
* When set, all other model attributes will be ignored.
|
||||
*/
|
||||
public abstract void setModelKey(String modelKey);
|
||||
|
||||
/**
|
||||
* Filter out undesired attributes from the given model.
|
||||
* The return value can be either another {@link Map} or a single value object.
|
||||
* @param model the model, as passed on to {@link #renderMergedOutputModel}
|
||||
* @return the value to be rendered
|
||||
*/
|
||||
protected abstract Object filterModel(Map<String, Object> model);
|
||||
|
||||
/**
|
||||
* Write a prefix before the main content.
|
||||
* @param generator the generator to use for writing content.
|
||||
* @param object the object to write to the output message.
|
||||
*/
|
||||
protected void writePrefix(JsonGenerator generator, Object object) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -245,7 +243,6 @@ public abstract class AbstractJackson2View extends AbstractView {
|
||||
* @param object the object to write to the output message.
|
||||
*/
|
||||
protected void writeSuffix(JsonGenerator generator, Object object) throws IOException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.springframework.web.servlet.View;
|
||||
*
|
||||
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
|
||||
*
|
||||
* <p>Compatible with Jackson 2.1 and higher.
|
||||
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
|
||||
*
|
||||
* @author Jeremy Grelle
|
||||
* @author Arjen Poutsma
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ import org.springframework.web.servlet.view.json.AbstractJackson2View;
|
||||
*
|
||||
* <p>The default constructor uses the default configuration provided by {@link Jackson2ObjectMapperBuilder}.
|
||||
*
|
||||
* <p>Compatible with Jackson 2.1 and higher.
|
||||
* <p>Compatible with Jackson 2.6 and higher, as of Spring 4.3.
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
* @since 4.1
|
||||
|
||||
Reference in New Issue
Block a user