此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【benben525】截止到2008-07-09 08:53:47的历史汇总数据(不包括此帖):
发帖的总数量:0                        发帖的总分数:0                        每贴平均分数:0                        
回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
结贴的总数量:0                        结贴的总分数:0                        
无满意结贴数:0                        无满意结贴分:0                        
未结的帖子数:0                        未结的总分数:0                        
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html

解决方案 »

  1.   

    处理中文乱码用
    String a = new String(a.getByte("ISO-8859-1"),"GB2312");来处理一下啊 
      

  2.   

    用Filter来处理.在web.config里配一个Filter.他的<url-parten>/*</>然后在建的Filter里写request.setchar.....("GBK")
      

  3.   

    看页面的配置,如果是gbk就
    String a = new String(a.getByte("ISO-8859-1"),"gbk");
    如果是utf-8就
    String a = new String(a.getByte("ISO-8859-1"),"utf-8");
    如果是gbk2312就
    String a = new String(a.getByte("ISO-8859-1"),"gb2312");楼主还可用filter来做,这个比较彻底,一下子全转码了,google一大堆
      

  4.   

    String a = new String(a.getByte("ISO-8859-1"),"GB2312");
      

  5.   

    写一个过滤器Filter Java code
    你说的登录时候设置request.getSession(true).setAttribute("login", user);public class LoginFilter implements Filter{
        public void doFilter( ServletRequest request ,ServletResponse response ,FilterChain chain )
                throws ServletException ,IOException
        {
                 HttpServletRequest req = (HttpServletRequest)request; 
                    HttpSession session = req.getSession( true ) ;
            Object obj = session.getAttribute( "login" ) ;
            if( obj != null ){
                chain.doFilter( request , response ) ;
            }else{
                HttpServletResponse res = (HttpServletResponse)response ;
                res.sendRedirect( "login.jsp" ) ;
            }}在web.xml中配置 XML code
    <filter>
        <filter-name>loginFilter</filter-name>
            <filter-class>LoginFilter</filter-class>
        </filter>
        <filter-mapping>
            <filter-name>loginFilter</filter-name>
            <url-pattern>/*</url-pattern> <!--写你需要通过登陆才能访问的页面-->
        </filter-mapping>    
    <filter>这样你在整个项目上需要登陆后才能访问的页面只需在web.xml中 <url-pattern> </url-pattern>指明就可以了
      

  6.   

    像这一类的转码都有一定的问题,会产生奇偶效应。偶数位结束完整,奇数位结束丢失。
    String a = new String(a.getByte("ISO-8859-1"),"gbk"); 
    至于设定编码格式,也不能完全解释中文转码问题。
    转成byte传入后台。看看可以不。
      

  7.   

    String a=new String(request.getParameter("a").getBytes("iso-8859-1"),"UTF-8");
    或者在web.xml中写过滤器
      

  8.   

    在web.xml中设置filter,在filter中设置编码格式
    public void doFilter(ServletRequest arg0, ServletResponse arg1, FilterChain arg2) throws IOException, ServletException {
    arg0.setCharacterEncoding("GBK");
    arg2.doFilter(arg0, arg1);
    }
      

  9.   

    首先要保证项目是UTF-8的 这样比较好转
      

  10.   

    在web.xml中配一个过虑器就行了
      

  11.   

    写一个过滤器package com.sunnyit.filter;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 FilterEncoding implements Filter {

        private FilterConfig filterConfig=null;
        private String encoding=null;
        
        //初始化过滤器
        public void init(FilterConfig filterConfig) throws ServletException {
               
         this.filterConfig=filterConfig;
            this.encoding=filterConfig.getInitParameter("encoding");
        }
        
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
               String encoding=this.encoding;
               if(encoding!=null)
               {
               //设置字符集
               request.setCharacterEncoding(encoding);
               }
               chain.doFilter(request, response);
        }
        //过滤器销毁
        public void destroy() {
               this.encoding=null;
               this.filterConfig=null;
        }
    }
      

  12.   

    在jsp页面里设置编码。
    <head>加上这句
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">