wt., 30 gru 2025 o 12:56 Ing. Andrea Vettori <[email protected]> napisał(a): > > Hello, > I’m facing an issue and I think it’s a “bug” on StreamResult (not sure about > it however). > > I know I can pass or do not pass a parameter contentCharSet on the result in > struts.xml. If I do not pass it, for some reason I find UTF-8 is added > automatically. > > However if I do pass a value that is an expression I would expect that if the > expression evaluates to null, the charset would not be added to the headers. > What happens instead is that a > > ;charSet= > > string is added to the content type. > > The “bug” is likely related to this code in StreamResult.java > > if (contentCharSet != null && !contentCharSet.isEmpty()) { > oResponse.setContentType(conditionalParse(contentType, > invocation) + ";charset=" + conditionalParse(contentCharSet, invocation)); > } else { > oResponse.setContentType(conditionalParse(contentType, > invocation)); > }
This looks like a bug, feel free to register a JIRA ticket. > So my questions are : > > 1. why I find UTF-8 if I don’t specify the parameter; > 2. shouldn’t the if check the emptiness of the evaluated expression in the > code above ? Also the "struts.i18n.encoding" and Dispatcher#prepare() method can be problematic, depending on your servlet container. Maybe we should always forcefully set character encoding in a result to reset the default behaviour. Please register a ticket and I can work on a solution. Cheers Łukasz --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
