<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)航:
     
    主站蜘蛛池模板: 99re6在线视频精品免费| 亚洲最大福利视频| 农村寡妇一级毛片免费看视频| 丁香花在线观看免费观看| 激情五月亚洲色图| 91九色精品国产免费| 亚洲色偷偷偷网站色偷一区| 又大又硬又爽又粗又快的视频免费| 亚洲精品福利视频| 最近免费中文在线视频| 91亚洲国产成人久久精品| 亚洲一区免费在线观看| 亚洲中文字幕无码av| 日本一区免费电影| 边摸边脱吃奶边高潮视频免费| 波多野结衣中文一区二区免费 | a毛片免费观看完整| 亚洲va中文字幕无码久久不卡| 日韩免费在线观看视频| 亚洲午夜一区二区电影院| 午夜视频在线观看免费完整版| www亚洲精品久久久乳| 亚洲欧洲精品成人久久奇米网| 美女无遮挡拍拍拍免费视频| 亚洲va在线va天堂va不卡下载| 免费A级毛片无码A∨免费| 亚洲精品无码久久久久秋霞| 人人狠狠综合久久亚洲高清| 精品国产免费一区二区三区| 亚洲视屏在线观看| 国产精品免费看久久久无码| 国产免费内射又粗又爽密桃视频 | 亚洲熟妇av一区二区三区下载| 成人在线视频免费| 一区二区三区免费视频播放器 | 日本人的色道www免费一区| 成在人线av无码免费高潮水| 亚洲精品国产专区91在线| 五月天婷亚洲天综合网精品偷| 青青草原1769久久免费播放| 在线观看亚洲AV日韩A∨|