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

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

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

    freefly
    一門技術(shù),如果不能講出來,那么就是沒有理解,如果不能很好的講出來,那么就是理解不夠透徹!
    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

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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 亚洲乱码中文字幕小综合| 激情综合色五月丁香六月亚洲| 久久精品国产精品亚洲色婷婷| 老司机午夜精品视频在线观看免费 | 天天摸天天碰成人免费视频| 亚洲高清日韩精品第一区| 18禁男女爽爽爽午夜网站免费| 日本亚洲欧洲免费天堂午夜看片女人员 | 99在线精品免费视频九九视| 亚洲国产精品久久网午夜| 曰批全过程免费视频播放网站| 亚洲人成电影在在线观看网色| 免费无码VA一区二区三区| 亚洲美女自拍视频| 免费在线观看视频网站| 亚洲国产日韩在线| 一个人免费高清在线观看| 亚洲熟女综合色一区二区三区| 日本人的色道www免费一区| 美女视频黄a视频全免费网站色 | 噜噜嘿在线视频免费观看| 亚洲男人天堂2018av| 尤物永久免费AV无码网站| 人妻无码中文字幕免费视频蜜桃| 亚洲欧洲自拍拍偷精品 美利坚| 中文字幕手机在线免费看电影| 亚洲av日韩av无码| 成熟女人牲交片免费观看视频| 亚洲精品无码专区| 亚洲一级片免费看| 最近免费中文字幕大全免费| 亚洲中文字幕日本无线码| 国产成人免费福利网站| a级精品九九九大片免费看 | 亚洲色图激情文学| 免费人成在线观看网站品爱网日本| 亚欧乱色国产精品免费视频| 亚洲天天在线日亚洲洲精| 成人免费淫片在线费观看| eeuss影院ss奇兵免费com| 亚洲尹人九九大色香蕉网站|