用eWebEditor传递中文乱码问题

bear_liu01 2009-01-10 03:50:19
传递页面:
<form name="myform" action="eWebEditor/submit.jsp" method="post">
<table class="data_list_table">
<tr>
<th>生产计划</th>
</tr>
<%
if(role.equals("管理员"))
{
%>
<tr>
<INPUT type="hidden" name="content1" value="<p> </p><p><font color=#ff0000>本样式为自带默认样式,最佳调用宽度650px,高度350px!</font></p><p>下面为一些高级调用功能的例子,你可以用脚本方便的编辑进行一些操作。</p><p>看到这些内容,且没有错误提示,说明安装已经正确完成!</p><p>您现在使用的是飞鱼修改版,有什么问题请到http://www.fiyu.net提出!</p>">
<td height="213" class="list_data_text"><IFRAME ID="eWebEditor1" src="eWebEditor/eWebEditor.jsp?id=content1&style=standard" frameborder="0" scrolling="no" width="650" height="350"></IFRAME></td>
</tr>
<TR>
<TD colspan=2 align=right>
<INPUT type=submit name=b1 value="提交">
<INPUT type=reset name=b2 value="重填">
<INPUT type=button name=b3 value="查看源文件" onclick="location.replace('view-source:'+location)">
</TD>
</TR>
<% }else
{
%>
<tr>
<td height="213" class="list_data_text"><textarea name="plantest" cols="110" rows="30" readonly="true"><%=plan %></textarea></td>
</tr>

<% }
%>

</table>
</form>
...全文
469 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dou_ye 2009-01-10
  • 打赏
  • 举报
回复
你把要传的字符串现在本页面alert出来看看是不是乱码,然后统一两个页面的编码再试试。
bear_liu01 2009-01-10
  • 打赏
  • 举报
回复
接受页面

<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>

<%@ page import="java.io.FileInputStream"%>
<%@ page import="java.io.FileOutputStream"%>
<%@ page import="java.nio.ByteBuffer"%>
<%@ page import="java.nio.channels.FileChannel"%>
<%@ page import="java.nio.charset.Charset"%>
<%



String sContent = new String(request.getParameter("content1").getBytes("GBK"),"GBK");
System.out.println();
System.out.println();
System.out.println();
System.out.println();
System.out.println();
System.out.print("取得的html标记:"+"\n"+sContent+"\n"+"主要问题可能出现在upload.jsp里的第202行的setHtml()");
out.println("编辑的内容如下:<br><br>"+sContent);
out.println(
"<br><br><p><input type=button value=' 退回 ' onclick='history.back()'></p>");

//System.out.println(sContent);
//得到项目的相对路径

String path=request.getContextPath();

//得到计划存放的路径
String planpath=path+"/plantxt";
FileChannel fc=new FileOutputStream(request.getRealPath("aa.doc")).getChannel();
System.out.println(fc);
//getBytes()使用平台默认的字符集将此 String 解码为字节序列,并将结果存储到一个新的字节数组中。
//System.out.println(pf.getContent1().getBytes());
fc.write(ByteBuffer.wrap(sContent.getBytes()));
fc.close();
%>
kao331431214 2009-01-10
  • 打赏
  • 举报
回复
编码要统一

81,094

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧