当前位置: 首页>>代码示例>>Java>>正文


Java WebUtils.CONTENT_TYPE_CHARSET_PREFIX属性代码示例

本文整理汇总了Java中org.springframework.web.util.WebUtils.CONTENT_TYPE_CHARSET_PREFIX属性的典型用法代码示例。如果您正苦于以下问题:Java WebUtils.CONTENT_TYPE_CHARSET_PREFIX属性的具体用法?Java WebUtils.CONTENT_TYPE_CHARSET_PREFIX怎么用?Java WebUtils.CONTENT_TYPE_CHARSET_PREFIX使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.web.util.WebUtils的用法示例。


在下文中一共展示了WebUtils.CONTENT_TYPE_CHARSET_PREFIX属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureResponse

/**
 * Configure the supplied {@link HttpServletResponse}.
 * <p>The default implementation of this method sets the
 * {@link HttpServletResponse#setContentType content type} and
 * {@link HttpServletResponse#setCharacterEncoding encoding}
 * from the "media-type" and "encoding" output properties
 * specified in the {@link Transformer}.
 * @param model merged output Map (never {@code null})
 * @param response current HTTP response
 * @param transformer the target transformer
 */
protected void configureResponse(Map<String, Object> model, HttpServletResponse response, Transformer transformer) {
	String contentType = getContentType();
	String mediaType = transformer.getOutputProperty(OutputKeys.MEDIA_TYPE);
	String encoding = transformer.getOutputProperty(OutputKeys.ENCODING);
	if (StringUtils.hasText(mediaType)) {
		contentType = mediaType;
	}
	if (StringUtils.hasText(encoding)) {
		// Only apply encoding if content type is specified but does not contain charset clause already.
		if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
			contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
		}
	}
	response.setContentType(contentType);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:XsltView.java

示例2: renderReportUsingWriter

/**
 * We need to write text to the response Writer.
 * @param exporter the JasperReports exporter to use
 * @param populatedReport the populated {@code JasperPrint} to render
 * @param response the HTTP response the report should be rendered to
 * @throws Exception if rendering failed
 */
protected void renderReportUsingWriter(net.sf.jasperreports.engine.JRExporter exporter,
		JasperPrint populatedReport, HttpServletResponse response) throws Exception {

	// Copy the encoding configured for the report into the response.
	String contentType = getContentType();
	String encoding = (String) exporter.getParameter(net.sf.jasperreports.engine.JRExporterParameter.CHARACTER_ENCODING);
	if (encoding != null) {
		// Only apply encoding if content type is specified but does not contain charset clause already.
		if (contentType != null && !contentType.toLowerCase().contains(WebUtils.CONTENT_TYPE_CHARSET_PREFIX)) {
			contentType = contentType + WebUtils.CONTENT_TYPE_CHARSET_PREFIX + encoding;
		}
	}
	response.setContentType(contentType);

	// Render report into HttpServletResponse's Writer.
	JasperReportsUtils.render(exporter, populatedReport, response.getWriter());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:AbstractJasperReportsSingleFormatView.java


注:本文中的org.springframework.web.util.WebUtils.CONTENT_TYPE_CHARSET_PREFIX属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。