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

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

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

    posts - 32,  comments - 149,  trackbacks - 0
    1. 首先所有的文字編碼均采用UTF-8格式,至于為什么要采用UTF-8.  
    <%@ page language="java" contentType="text/html; charset=utf-8" %>

    2. struts框架提供了資源信息文件,它包含了jsp頁面內容的一些文字說明,以及另一些供代碼中使用的信息輸出等(說白了,就是些文字描述定義,可以當成變量看待)。
    ApplicationResources.properties(默認的是英文ApplicationResources.properties一份,命名為:ApplicationResources_zh_CN.properties 簡體中文
    ApplicationResources_zh_TW.properties 繁體中文
     
    然后,執行JDK自帶的命令如下:
    native2ascii -encoding gb2312 ApplicationResources_demo.properties ApplicationResources_zh_CN.properties
    3. struts中,對于中文參數的傳遞的文字編碼處理,一般加個過濾器類就可以了的。
    java源代碼如下:

    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;
    import javax.servlet.UnavailableException;


    public class SetCharacterEncodingFilter 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 request, ServletResponse response,FilterChain chain)
    ???throws IOException, ServletException
    ?{
    ??if (ignore || (request.getCharacterEncoding() == null))
    ??{
    ???String encoding = selectEncoding(request);
    ???if (encoding != null)
    ????request.setCharacterEncoding(encoding);
    ??}
    ??chain.doFilter(request, response);
    ?}

    ?public void init(FilterConfig filterConfig) throws ServletException
    ?{
    ??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;
    ?}

    ?protected String selectEncoding(ServletRequest request)
    ?{
    ??return (this.encoding);
    ?}
    }
    4.? 配置web.xml文件

    ? 在<web-app>下加下面的代碼

    <filter>
    ?<filter-name>Set Character Encoding</filter-name>
    ?<filter-class>com.zxjsoft.util.SetCharacterEncodingFilter</filter-class>
    ?<init-param>
    ??<param-name>encoding</param-name>
    ??<param-value>utf-8</param-value>
    ?</init-param>
    ?<init-param>
    ??<param-name>ignore</param-name>
    ??<param-value>true</param-value>
    ?</init-param>
    </filter>

    <filter-mapping>
    ?<filter-name>Set Character Encoding</filter-name>
    ?<servlet-name>action</servlet-name>
    </filter-mapping>

    5.對于hibernate如說 還得配置hibernate.cfg.xml文件
    ?在文件里加入
    ?<property name="hibernate.connection.useUnicode">true</property>
    ?<property name="hibernate.connection.characterEncoding">UTF-8(或者gb2312)</property>

    posted on 2007-01-15 13:00 chunkyo 閱讀(598) 評論(0)  編輯  收藏 所屬分類: openSource(struts&hibernate&spring等等)
    <2007年1月>
    31123456
    78910111213
    14151617181920
    21222324252627
    28293031123
    45678910

    這個博客主要是關于java技術和開源技術,大家一起來進步了!

    常用鏈接

    留言簿(12)

    隨筆分類

    隨筆檔案

    文章分類

    收藏夾

    DotNet

    Java技術網站

    Linux VS Unix

    其他常去網站

    常光顧的BLOG

    文學類網站

    游戲類網站

    最新隨筆

    搜索

    •  

    積分與排名

    • 積分 - 197152
    • 排名 - 293

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 亚洲精品乱码久久久久久V| 你懂的免费在线观看| 色九月亚洲综合网| 羞羞漫画小舞被黄漫免费| 久久综合九色综合97免费下载| 国产成人免费高清激情视频| 亚洲三区在线观看无套内射| 亚洲成_人网站图片| 成人免费一区二区三区| 国产精品成人免费一区二区| 亚洲熟伦熟女专区hd高清| 日韩精品无码免费专区午夜不卡| 成人免费在线观看网站| 久久国产精品亚洲一区二区| 久久亚洲精品无码gv| 久视频精品免费观看99| 亚洲熟妇av一区二区三区| 十八禁在线观看视频播放免费| 亚洲成AV人片在线观看WWW| 亚洲天堂免费在线视频| 成人免费a级毛片| 亚洲另类无码专区首页| 久久福利资源网站免费看| 久久久久亚洲av无码尤物| 18禁黄网站禁片免费观看不卡| 亚洲伊人精品综合在合线| 18女人水真多免费高清毛片| 亚洲人成在线中文字幕| 免费看片A级毛片免费看| 国产成人精品日本亚洲专| 亚洲网站在线免费观看| 亚洲精品中文字幕| 亚洲日韩在线观看| 一区二区三区免费视频观看 | 1000部拍拍拍18勿入免费视频下载 | 国产午夜亚洲精品国产成人小说| 亚洲欧美精品午睡沙发| 亚洲狠狠爱综合影院婷婷| 亚洲欧洲免费无码| 亚洲国产综合专区电影在线| 中文在线日本免费永久18近|