pyk_yj 2017-09-21 12:28 采纳率: 0%
浏览 746

jsp页面中的表格使用Word打开中文显示乱码

在一个jsp页面中放了一个表格,内容有中文,使用浏览器打开,表格内容正常显示。在
这个jsp页面中加入response.setContentType("application/msword;charset=UTF-8");
希望使用word方式显示这个页面,word能正常打开,但是中文显示乱码。附上代码,
感谢万分。
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="cn.java.mydoc.bean.Profile"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("UTF-8");
response.setContentType("application/msword;charset=UTF-8");
%>
<%
Profile profile = (Profile)request.getAttribute("profile");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">




编号
<%= profile.getId() %>


姓名
<%= profile.getName() %>


生日
<%= profile.getBirthday() %>


性别
<%= profile.getGender() %>


职业
<%= profile.getCareer() %>


住址
<%= profile.getAddress() %>


电话
<%= profile.getMobile() %>



  • 写回答

1条回答 默认 最新

  • 是镜花水月 2017-09-22 04:53
    关注

    乱码就是编码不对了,word默认有可能是gbk或者其他编码

    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退