任何人都可以告诉我如何将内容类型设置为" UTF-8"使用动作响应,如资源响应?
我没有看到actionResponse的任何setContentType。
在资源映射中,我们可以像
那样做 resourceResponse.setContentType("text/html; charset=UTF-8");
我还尝试使用。
对字符串进行编码messageToCust=new String (messageToCust.getBytes ("ISO-8859-1"), "UTF-8");
我还有其他方法可以设置内容类型吗?
答案 0 :(得分:0)
您应该从actionResponse获取HttpServletResponse,如下所示:
HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(actionResponse);
httpResponse.setContentType("text/html; charset=UTF-8");