本人使用myeclipse开发ckeditor应用,在ie6、ie7、谷歌浏览器上可以显示出ckeditor组件,在ie8、ff上不能显示ekeditor组件,提示为:CKEDITOR未定义,后经过验证得出在web.xml文件中的jsp过滤器的问题:
    <filter>
<filter-name>encoding</filter-name>
<filter-class>bean.util.cn.EncodingFilter</filter-class>
<init-param>
    <param-name>encoding</param-name>
    <param-value>GBK</param-value>
</init-param>
    </filter> 

    <filter-mapping>
        <filter-name>encoding</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> 
将GBK改为UTF-8后所有的浏览器都不出现问题,显示、应用正常,表单提交后汉字出现乱码;改成GBK后出现上述问题。后来发现ckeditor所有的js文件都为UTF-8(BOM)编码,我利用EditPlus将开始的几个(从httplook中看出最初调用了几个js文件)js文件的编码都改为gb2312后,利用浏览器(所有浏览器)直接打开ckeditor中的simple的index.html调用组件不出现。将js编码改为utf-8后,浏览器(所有浏览器)直接打开组件使用正常,但是在myeclipse中运行应用后,还是出现上述问题。请各位高手指点,急!!!!

解决方案 »

  1.   

    调用js 的地方 加上编码试试<script type="text/javascript" src="XXX.js" charset="utf-8"></script>
      

  2.   


    怎么编码那么乱的
    你在调用ckeditor的
    jsp也utf-8呀
      

  3.   

    filter的代码:
    package bean.mjq.util.cn;import java.io.IOException;import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;public class EncodingFilter implements Filter{
    protected String encoding = null;
    protected FilterConfig config;
    public void destroy() { }
     
    public void doFilter(ServletRequest request, ServletResponse response,
    FilterChain chain) throws IOException, ServletException {
    if(request.getCharacterEncoding()==null){
    String encode = this.encoding;
    if(encode!=null){
    request.setCharacterEncoding(encode);
    response.setCharacterEncoding(encode);
    }
    }
    chain.doFilter(request,response);
    } public void init(FilterConfig arg0) throws ServletException {
    this.config = arg0;
    this.encoding = arg0.getInitParameter("encoding");

    }

    }JSP的代码:<%@ page contentType="text/html; charset=GBK" pageEncoding="GBK"%>
    <%@ page isELIgnored="false"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
        
        <title>My JSP 'index.jsp' starting page</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <script type="text/javascript" src="ckeditor/ckeditor.js" charset="utf-8"></script>
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
      </head>
      
      <body>
        <form method="post"  enctype="multipart/form-data">
        <textarea cols="80" id="editor1" name="editor1" rows="10"></textarea>
    <script type="text/javascript">
    CKEDITOR.replace( 'editor1',  
    {  
             filebrowserImageUploadUrl : 'servlet/upload'  
    });  
    </script>
    </form>
      </body>
    </html>ckeditor所有的编码都是utf-8(BOM)格式,直接从ckeditor网站上下的,jsp文件的编码都是gb2312(我整个workplace的设置都是jsp都是gb2312)
      

  4.   

    jsp的编码换成UTF-8也不成,目前只有将<filter>里面的编码换成UTF-8所有浏览器才成,郁闷之极