servlet 文件的内容
String opration = rs.getString("index.opration");
String serverCard = rs.getString("index.serverCard");
String statistics = rs.getString("index.statistics");
String visitorCard = rs.getString("index.visitorCard");
String button = rs.getString("index.button");
String oprationOpration = rs.getString("opration.opration");
String oprationServiceOperation = rs.getString("opration.serviceOperation");
String oprationInvite = rs.getString("opration.invite");
String oprationOnlineState = rs.getString("opration.onlineState");
String oprationReceptSet = rs.getString("opration.receptSet");
String oprationWaitTime = rs.getString("opration.waitTime");
String oprationCheckInfo = rs.getString("opration.checkInfo");
String oprationlist = oprationOpration +","+ oprationServiceOperation +","+ oprationInvite +","+ oprationOnlineState +","+ oprationReceptSet
+","+oprationReceptSet +","+ oprationWaitTime +","+ oprationCheckInfo;
//XmlUtil xmlutil = new XmlUtil();
String strlist = opration +"," + serverCard +","+ statistics +","+ visitorCard +"," + button;
request.getSession().setAttribute("indexlist",strlist );
request.getSession().setAttribute("oprationlist",oprationlist );
request.setCharacterEncoding("GB2312");
//request.getRequestDispatcher("/opration.jsp").forward(request, response);
request.getRequestDispatcher("/index.jsp").forward(request, response);
jsp 文件的内容
<%@ page language="java" contentType="text/xml; charset=GB2312" pageEncoding="GB2312"%>
<%
request.setCharacterEncoding("GB2312");
String list = (String)request.getSession().getAttribute("indexlist");
if(list != null && list.trim().length() != 0){
String[] listvalue = list.split(",");
String opration = listvalue[0];
String serverCard = listvalue[1];
String statistics = listvalue[2];
String visitorCard = listvalue[3];
String button = listvalue[4];
System.out.println(list);
out.write("<?xml version=\"1.0\" encoding=\"GB2312\"?>");
out.write("<index>");
out.write("<statistics id=\""+statistics+"\">"+statistics+"</statistics>");
out.write("<opration>"+opration+"</opration>");
out.write("<serverCard>"+serverCard+"</serverCard>");
out.write("<button>"+button+"</button>");
out.write("</index>");
}else{
out.write("The data is not found");
}
%>
------解决方案--------------------------------------------------------
关键是你的中文资源文件进行转码操作了吗?
------解决方案--------------------------------------------------------
去出来就是乱码还是你页面是乱码,我怎么怀疑你页面是乱码,页面改成UTF-8试试。
------解决方案--------------------------------------------------------
String opration = rs.getString("index.opration");
打断点看看是否为乱码,如果不是乱码就是页面问题。
------解决方案--------------------------------------------------------
<%@ page language="java" pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("GB2312");删了
------解决方案--------------------------------------------------------
靠,你刚说xml是好的
out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>