加一个filter
  <filter>
    <filter-name>Set Character Encoding</filter-name>
    <filter-class>filters.SetCharacterEncodingFilter</filter-class>  --具体的转换类
    <init-param>
      <param-name>encoding</param-name>
      <param-value>GBK</param-value>
    </init-param>
  </filter>
  <filter-mapping>
    <filter-name>Set Character Encoding</filter-name>
    <url-pattern>*.jsp</url-pattern>
  </filter-mapping>下面是类代码
--filters.SetCharacterEncodingFilter
package filters;import java.io.IOException;import javax.servlet.*;public class SetCharacterEncodingFilter implements Filter
{
    protected String encoding = null;
    protected FilterConfig filterConfig = null;
    protected boolean ignore = true;    public void destroy()
    {
        this.encoding = null;
        this.filterConfig = null;
    }    public void doFilter(ServletRequest request, ServletResponse response,
            FilterChain chain)
            throws IOException, ServletException
            {// Conditionally select and set the character encoding to be used
            if (ignore || (request.getCharacterEncoding() == null))
    {
        String encoding = selectEncoding(request);
        if (encoding != null)
        {
            request.setCharacterEncoding(encoding);
        }
    }
// Pass control on to the next filter
    chain.doFilter(request, response);    }            public void init(FilterConfig filterConfig)
            throws ServletException
    {        this.filterConfig = filterConfig;
        this.encoding = filterConfig.getInitParameter("encoding");
        String value = filterConfig.getInitParameter("ignore");
        if (value == null)
        {
            this.ignore = true;
        }
        else if (value.equalsIgnoreCase("true"))
        {
            this.ignore = true;
        }
        else if (value.equalsIgnoreCase("yes"))
        {
            this.ignore = true;
        }
        else
        {
            this.ignore = false;
        }    }    protected String selectEncoding(ServletRequest request)
    {
        return (this.encoding);
    }}

解决方案 »

  1.   

    楼上你好!我按照你的方法使用了,由于我传递这些阐述是通过javascript来完成,我把
    <filter-mapping> 
        <filter-name>Set Character Encoding </filter-name> 
        <url-pattern>*.jsp </url-pattern> 
      </filter-mapping> 
    中的*.jsp 改为*.htm但是还是一样的错误!还是感谢你了!
      

  2.   

      1、weblogic.xml中的设置将影响所有页面的编译时使用的编码方式
     <jsp-param>
         <param-name>compilerSupportsEncoding</param-name>
         <param-value>true</param-value>
     </jsp-param>
     <jsp-param>
       <param-name>encoding</param-name>
         <param-value>GBK</param-value>
     </jsp-param>
        以上设置相当于给所有JSP文件添加<%@ page language="java" contentType="text/html;charset=GBK"%>,这将使页面上的中文提示信息可以正常显示
        2、web.xml中设定的Encoding将设置JSP文件之间传递数据使用的编码形式(即影响所有页面里面的request.getCharacterEncoding())
        3、form提交的数据的编码形式:
     Get的编码方式是根据页面中指定的编码方式,而Post则是一直使用同一种编码方式,在web.xml中设置,具体如下:
     <context-param><param-name>weblogic.httpd.inputCharset./*</param-name>
         <param-value>UTF-8</param-value>
     </context-param>看看上面能不能解决这个问题,在已上线的一个项目中也碰到了此类问题,我研究了好久好久,都没有找到解决方案,
    配置文件也改了,该改的地方都试过了,就是没有用,在tomcat中这个问题很好解决,本来我们项目是用tomcat的,但后来
    改用weblogic了