Google Appengine Cloud 不支持 JSP/Servlet 响应中的 unicode 字符吗?
我正在向部署在 Google Appengine 服务器上的应用程序发出请求。应用程序返回 unicode 格式的响应。如果我通过开发服务器访问响应,它正如我预期的那样很好,但是当我部署到 Google 生产应用引擎服务器上时,这一切都出现了一个问号,如下所示 "header":"������������������������”
如果您查看 servlet 的源代码,我确保以下内容已经就位,
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
请帮忙。
I am making a request to my application deployed on to Google Appengine server. The application returns a response which is in unicode. The response if I access through development server, it comes nicely as I expected it, but when I deployed on to Google production appengine server, it all comes a question marks as following
"header":"������������������������"
if you look at the source of servlet, I ensured that following is already in place
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我刚刚尝试从 JSP 页面返回 UTF-8 字符,它们似乎可以正确呈现。在 JSP 中,我有
并在 head。未在 Servlet 中设置有关响应内容类型或编码的任何内容。
我还尝试在本地和部署的数据存储中检索和存储 UTF-8 数据,并且它在这两种情况下都能正确呈现所有 UTF-8 字符。
这是 Servlet:
和 JSP:
I just tried returning UTF-8 characters from a JSP page and they seem to render correctly. In the JSP I have
<jsp:directive.page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" />
and in head<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
. Not setting anything about content type or encoding to response in the Servlet.I also tried retrieving and storing UTF-8 data to and from the datastore both locally and deployed and it renders all the UTF-8 characters properly on both occasions.
Here's the Servlet:
And the JSP:
我也遇到了这个问题 - 我的 jsp 中的某些 unicode 字符(例如 →)在开发服务器中渲染得很好,但在部署到 appengine 中时却无法渲染。即使 html 头部包含 .
解决方案是添加
到jsp文件的顶部。
I was having this problem as well -- certain unicode characters in my jsp (such as →) rendered fine with the development server, but not when deployed in appengine. This even though the html head contained .
The solution was to add
to the top of the jsp file.