同时也要转到另一个页面,传递过去中文。

解决方案 »

  1.   

    写个过滤器类 ,在 Web.xml 中配置  就OK了  不是大问题 
      

  2.   

    像LS说的说如果从大局看最后写个过滤器为后面的操作减少很多不必要的麻烦http://www.pmjava.com/blogview.asp?id=303http://www.pmjava.com/blogview.asp?id=187http://www.pmjava.com/blogview.asp?id=133
      

  3.   

    我把用户发送请求方式不同引起的中文问题划分了四种类型(这里未提及数据库):1、表单的get提交2、表单的post提交3、页面链接传递中文参数4、地址栏中参数直接输入中文提交lz可以看下http://www.javaeye.com/topic/300656
      

  4.   

    或者用post提交。
    如果非得用get方式提交,先转码,接收的时候再往回转码。
      

  5.   


    麻烦给我一份吧。
    email:[email protected]
      

  6.   

    中文外面加上java.net.URLEncoder("你的中文","utf-8"),编码根据你用的情况改
      

  7.   

    处理乱码的方法有很多最优的解决可以看下面文章
    http://blog.csdn.net/leves1989/archive/2008/11/08/3251253.aspx
      

  8.   

    写个过滤器类是最好的解决办法。还可以通过设置tomcat中的<connector>在这个里面添加URLEncoding="utf-8"
      

  9.   

    1、写个过滤器,可以解决大部分问题。
    2、javascript传参数前先URLEncoding,再传。
    3、最好所有页面都用utf-8
      

  10.   

    如果服务器是tomcat的话,可以修改配置文件。我博客上有!
      

  11.   

    package com.elec.tool;import java.io.IOException;import javax.servlet.*;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;public class EncodingChange 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 requests, ServletResponse responses,
    FilterChain chain) throws IOException, ServletException {
    // TODO Auto-generated method stub
    HttpServletRequest request=(HttpServletRequest)requests;
    HttpServletResponse response=(HttpServletResponse)responses;
    if(ignore||request.getCharacterEncoding()==null){
    String encoding=selectEncoding(request);
    if(encoding!=null){
    request.setCharacterEncoding(encoding);
    request.getSession().getAttribute("Login_Student");
    request.getSession().getAttribute("Login_Teacher");
    request.getSession().getAttribute("Login_Admin");
    }
    }
    chain.doFilter(request, response);
    }

    public void init(FilterConfig filterconfig) throws ServletException {
    // TODO Auto-generated method stub
    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; 

    }
    public String selectEncoding(ServletRequest request){
    return this.encoding;
    }
    }
    ...........................web.xml<filter> 
    <filter-name>setCharacterEncoding</filter-name> 
    <filter-class> 
    com.elec.tool.EncodingChange
    </filter-class> 
    <init-param> 
    <param-name>ignore</param-name> 
    <param-value>true</param-value> 
    </init-param> <init-param> 
    <param-name>encoding</param-name> 
    <param-value>UTF-8</param-value> 
    </init-param>   
    </filter> 
    <filter-mapping> 
    <filter-name>setCharacterEncoding</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping> 
      

  12.   

    public static final String toUnicode(String str){    try{
           str= new String(str.getBytes("gb2312"),"iso-8859-1");    } catch(Exception e){
        
        }   return str
    }
    这个是一个公共的方法。把这个方法放在一个类中,在任何地方引用这个方法就可以了。这个方法是来处理中文里面的乱码。注意:统一字符串不能两次处理,不然又出现乱码了。