Skip to content

Commit d418eed

Browse files
committed
AbstractJasperReportsView only sets locale model attributes if not present already
1 parent 244c961 commit d418eed

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/view/jasperreports/AbstractJasperReportsView.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ protected void renderMergedOutputModel(
568568
* Expose current Spring-managed Locale and MessageSource to JasperReports i18n
569569
* ($R expressions etc). The MessageSource should only be exposed as JasperReports
570570
* resource bundle if no such bundle is defined in the report itself.
571-
* <p>Default implementation exposes the Spring RequestContext Locale and a
571+
* <p>The default implementation exposes the Spring RequestContext Locale and a
572572
* MessageSourceResourceBundle adapter for the Spring ApplicationContext,
573573
* analogous to the <code>JstlUtils.exposeLocalizationContext</code> method.
574574
* @see org.springframework.web.servlet.support.RequestContextUtils#getLocale
@@ -580,9 +580,12 @@ protected void renderMergedOutputModel(
580580
*/
581581
protected void exposeLocalizationContext(Map<String, Object> model, HttpServletRequest request) {
582582
RequestContext rc = new RequestContext(request, getServletContext());
583-
model.put(JRParameter.REPORT_LOCALE, rc.getLocale());
583+
if (!model.containsKey(JRParameter.REPORT_LOCALE)) {
584+
model.put(JRParameter.REPORT_LOCALE, rc.getLocale());
585+
}
584586
JasperReport report = getReport();
585-
if (report == null || report.getResourceBundle() == null) {
587+
if ((report == null || report.getResourceBundle() == null) &&
588+
!model.containsKey(JRParameter.REPORT_RESOURCE_BUNDLE)) {
586589
model.put(JRParameter.REPORT_RESOURCE_BUNDLE,
587590
new MessageSourceResourceBundle(rc.getMessageSource(), rc.getLocale()));
588591
}

0 commit comments

Comments
 (0)