You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "xue (Jira)" <ji...@apache.org> on 2020/12/02 03:50:00 UTC
[jira] [Commented] (WW-5100) incorrect content-type behavior after
upgrading to struts 2.5.*
[ https://issues.apache.org/jira/browse/WW-5100?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17242024#comment-17242024 ]
xue commented on WW-5100:
-------------------------
Hi, Lukasz,
1. My page is simple as below:
--------------------------------------------
<!DOCTYPE HTML><!DOCTYPE HTML><html> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" charset="utf-8"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge"></meta>
<script src="*js/sap/ui/thirdparty/d3.js*" charset="utf-8" ></script>
<script src="j*s/sap/ui/thirdparty/d3-dbg.js*" charset="utf-8" ></script>
<title><%=title%></title>
</head>
<body class="sapUiBody">
<div id="content_shell"> </div>
</body></html>
--------------------------------------------
2. I had a filer CharacterEncodingFilter as below, which add utf-8 charset in Content-Type.
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
servletRequest.setCharacterEncoding("utf-8");
servletResponse.setCharacterEncoding("utf-8");
filterChain.doFilter(servletRequest, servletResponse);
}
----------------------------------------------
3. my web.xml
----------------------------------------------
<filter> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>com.acta.webapp.mdreport.servlet.CharacterEncodingFilter</filter-class> </filter>
...
<filter-mapping> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
----------------------------------------------
3. then my response of the d3*.js is: "application/script;charset=UTF-8".
4. But the d3 ([https://github.com/d3/d3)] which has var *{color:#FF0000}π{color}* = Math.PI, *{color:#FF0000}ε{color}* = 1e-6 defined and encoded by UTF-8 can still not be loaded.
5. When I move my test html above and the d3 file into some other web applications without struts, for example the docs of tomcat, then everything works fine.
So my question is:
# I did not change anything about global.properties under struts-core jar, why in struts 2.5.* the Content-Type is changed by adding charset=ISO-8859-1 by default?
# Currently, I am able to change the Content-Type by adding UTF-8 by the code above, why the file is still not parsing by UTF-8?
And as it is a blocker issue of our product, please help to solve/advise,
Thanks,
Helen
> incorrect content-type behavior after upgrading to struts 2.5.*
> ---------------------------------------------------------------
>
> Key: WW-5100
> URL: https://issues.apache.org/jira/browse/WW-5100
> Project: Struts 2
> Issue Type: Bug
> Components: Core
> Affects Versions: 2.5.22
> Environment: Windows
> Reporter: xue
> Priority: Blocker
> Labels: features
> Fix For: 2.6
>
>
> 1. After upgrading from struts 2.3.* to struts 2.5.22, the content-type header of the response will changed to "application/script;charset=charset=ISO-8859-1" which was "application/script" in struts 2.3.4.
> Which caused our application failed, as it should be default as UTF-8.
> 2. When specifying the charset in Content-type with struts filer, the Content-Type is change to "application/script;charset=charset=UTF-8", but UTF-8 encoded file can still not be loaded correctly.
> It is blocker issue, which fails our application after upgrading.
> Please help to explain and provide solution, thanks,
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)