<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    freefly
    一門技術,如果不能講出來,那么就是沒有理解,如果不能很好的講出來,那么就是理解不夠透徹!
    posts - 9,comments - 3,trackbacks - 0

     Here is my solution for  mess code on page,hope this can help you!
     The point is your database coding should be consistent with the coding of  character that you plan to insert into the database.
     Attention: Here,I take "UTF-8" as default character coding way .
     There are three steps:
     1. set page charset 
         e.g      <%@ page language="java" contentType="text/html; charset=UTF-8" %>
        
     2. create character filter:
         package com.victory.util;

         import javax.servlet.http.HttpServlet;
         import javax.servlet.Filter;
         import javax.servlet.FilterConfig;
         import javax.servlet.ServletException;
         import javax.servlet.ServletRequest;
         import javax.servlet.ServletResponse;
         import javax.servlet.FilterChain;
         import javax.servlet.http.*;
         import java.io.IOException;
         public class CharacterEncodingFilter
           extends HttpServlet
           implements Filter {

           private FilterConfig filterConfig;
           private String targetEncoding = "ASCII";

         /**
          * Called by the web container to indicate to a filter that it is being placed
          * into service.
          *
          * @param filterConfig FilterConfig
          * @throws ServletException
          * @todo Implement this javax.servlet.Filter method
         */
          public void init(FilterConfig filterConfig) throws ServletException {
          this.filterConfig = filterConfig;
          this.targetEncoding = filterConfig.getInitParameter("encoding");
         }

        /**
         * The <code>doFilter</code> method of the Filter is called by the container
         * each time a request/response pair is passed through the chain due to a
         * client request for a resource at the end of the chain.
         *
         * @param request ServletRequest
         * @param response ServletResponse
         * @param chain FilterChain
         * @throws IOException
         * @throws ServletException
         * @todo Implement this javax.servlet.Filter method
         */
         public void doFilter(ServletRequest srequest, ServletResponse sresponse,
                           FilterChain chain) throws IOException, ServletException {
          try {
            HttpServletRequest request = (HttpServletRequest) srequest;
            request.setCharacterEncoding(targetEncoding);
            chain.doFilter(srequest, sresponse);
              }
          catch (ServletException sx) {
             filterConfig.getServletContext().log(sx.getMessage());
              }
          catch (IOException iox) {
             filterConfig.getServletContext().log(iox.getMessage());
            }
          }

        /**
         * Called by the web container to indicate to a filter that it is being taken
         * out of service.
         *
         * @todo Implement this javax.servlet.Filter method
         */
         public void destroy() {
           filterConfig = null;
           targetEncoding = null;
         }
      }
      
      3.config web.xml
        attention: add these to your web.xml
         <filter>
         <filter-name>EncodingFilter</filter-name>
         <filter-class>com.victory.util.CharacterEncodingFilter</filter-class>
         <init-param>
           <param-name>encoding</param-name>
           <param-value>UTF-8</param-value>
         </init-param>
        </filter>
        <filter-mapping>
        <filter-name>EncodingFilter</filter-name>
         <url-pattern>/*</url-pattern>
        </filter-mapping> 
      4.set database configration
         modify the file:    my.ini
         [client]     default-character-set=utf8 
         [mysqld]  default-character-set=utf8
      5.restart Mysql server
      6.modified your table coding way to utf8

         or ceate your table like this :
         CREATE TABLE `user` (
        `ID` int(11) NOT NULL auto_increment,
        `USERNAME` varchar(50) NOT NULL default '',
        `PASSWORD` varchar(50) NOT NULL default '',
         PRIMARY KEY  (`ID`)
         ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 
      7.restrart your tomcat sever

       OK,it's all.

       Authrougn I have sovled   my problem, I think I  don't have enough understanding for it,  So hope    communicate with you! 

       Attention:mess code also exist in your database,through page hasn't mess code.
       
         


       
      
           
         

    posted on 2006-03-23 13:07 freefly 閱讀(449) 評論(0)  編輯  收藏 所屬分類: StrutsJavaDatabaseHibernateSpring

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 成人a视频片在线观看免费| 久久精品国产免费| 成年性生交大片免费看| 亚洲人成77777在线观看网| 特级做A爰片毛片免费69| 精品日韩99亚洲的在线发布| 2021免费日韩视频网| 456亚洲人成在线播放网站| 无码国产精品一区二区免费式直播| 97久久精品亚洲中文字幕无码| 精品无码AV无码免费专区| 亚洲人精品亚洲人成在线| 好吊妞788免费视频播放| 亚洲第一成年网站视频| 亚洲国产精品视频| 免费h视频在线观看| 亚洲熟妇无码爱v在线观看| 中字幕视频在线永久在线观看免费 | 亚洲日韩精品国产3区| 一本久久综合亚洲鲁鲁五月天| 青青久久精品国产免费看| 亚洲国产另类久久久精品小说| 无码国产精品一区二区免费式芒果 | 在线视频免费国产成人| 乱人伦中文视频在线观看免费| 好看的电影网站亚洲一区| 国内精自视频品线六区免费| 亚洲国产欧美国产综合一区| 中文字幕亚洲无线码| 久久久久久精品免费看SSS| 含羞草国产亚洲精品岁国产精品| 亚洲综合最新无码专区| 中文字幕在线观看免费视频| 亚洲第一综合天堂另类专| 国产V亚洲V天堂无码| 在线看片免费不卡人成视频| 特级毛片A级毛片免费播放| 久久久久亚洲AV片无码下载蜜桃 | 在线观看亚洲免费视频| 中文字幕视频在线免费观看| 亚洲 欧洲 视频 伦小说|