在一个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() %>