本文整理汇总了Java中org.springframework.http.converter.json.MappingJackson2HttpMessageConverter.setPrettyPrint方法的典型用法代码示例。如果您正苦于以下问题:Java MappingJackson2HttpMessageConverter.setPrettyPrint方法的具体用法?Java MappingJackson2HttpMessageConverter.setPrettyPrint怎么用?Java MappingJackson2HttpMessageConverter.setPrettyPrint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
的用法示例。
在下文中一共展示了MappingJackson2HttpMessageConverter.setPrettyPrint方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
/**
* Render model and view.
*
* @param model the model
* @param response the response
*/
public static void render(final Object model, final HttpServletResponse response) {
try {
final MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
jsonConverter.setPrettyPrint(true);
final MediaType jsonMimeType = MediaType.APPLICATION_JSON;
jsonConverter.write(model, jsonMimeType, new ServletServerHttpResponse(response));
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
示例2: render
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
/**
* Render model and view.
*
* @param model the model
* @param response the response
*/
public static void render(final Object model, final HttpServletResponse response) {
try {
final MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
jsonConverter.setPrettyPrint(true);
final MediaType jsonMimeType = MediaType.APPLICATION_JSON;
jsonConverter.write(model, jsonMimeType, new ServletServerHttpResponse(response));
} catch (final Exception e) {
throw Throwables.propagate(e);
}
}
示例3: createJacksonHttpConverter
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; //导入方法依赖的package包/类
private HttpMessageConverter<Object> createJacksonHttpConverter() {
final MappingJackson2HttpMessageConverter jacksonConverter = new MappingJackson2HttpMessageConverter(brpJsonObjectMapper);
jacksonConverter.setPrettyPrint(true);
return jacksonConverter;
}