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

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

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

    狼愛上貍

    我胡漢三又回來了

    tomcat 5.0.28的問題

    1.配置成首頁的問題

    ? ??????? <Logger className="org.apache.catalina.logger.FileLogger"
    ???????????????? directory="logs"? prefix="localhost_log." suffix=".txt"
    ??????????? timestamp="true"/>
    ?????? ?這里增加:
    ???????? <Context path="" docBase="C:/Tomcat/webapps/myweb" debug="0" reloadable="true" crossContext="true"/>

    ? 要說的是myweb/web-inf/web.xml的文件最好改下名,我的從weblogic轉過來,看了很多論壇,因為這里沒改名,一直錯誤,還不知道怎回事,改了名就好了,該是沖突問題。

    2. 亂碼問題

    如果你沒有亂碼,不用看,有了亂碼,你就成亂麻,總得要解決,現在論壇有說這,有說那,只要解決了你的難題的,就是好方案。

    我的問題時,從數據庫中讀出沒亂碼,寫入出現亂碼,我的方案是:

    (1).在filters中做個SetCharacterEncodingFilter.java的bean文件。

    package filters;

    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 {

    // Conditionally select and set the character encoding to be used
    if (ignore || (request.getCharacterEncoding() == null)) {
    ?String encoding = selectEncoding(request);
    ?if (encoding != null)
    ?? request.setCharacterEncoding(encoding);
    }

    // Pass control on to the next filter
    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);
    }
    }

    編譯上段代碼時,要在classpath中注冊servlet.jar文件。
    (2).在web.xml中引入:

    <filter>
     <filter-name>Set Character Encoding</filter-name>
     <filter-class>filters.SetCharacterEncodingFilter</filter-class>
     <init-param>
      <param-name>encoding</param-name>
      <param-value>GBK</param-value>
     </init-param>
    </filter>

    <filter-mapping>
     <filter-name>Set Character Encoding</filter-name>
     <url-pattern>/*</url-pattern>
    </filter-mapping>

    (3)在server.xml中修改

    ??????????????? port="8080"??maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    ?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"
    ?????????????? debug="0" connectionTimeout="20000"
    ?????????????? disableUploadTimeout="true" URIEncoding="ISO-8859-1" />

    ???? 有種說法是把URIEncoding="ISO-8859-1"可換成URIEncoding="GBK",自己測試,對的就是硬道理。

    最后順便說下mysql-connector-java-5.0.3-bin.jar的jdbc連接代碼,與以前低版本的不一樣。

    String sDBDriver="com.mysql.jdbc.Driver";
    String sConnStr="jdbc:mysql://localhost:3306/gain?user=root&password=password";


    posted on 2006-10-12 23:08 狼愛上貍 閱讀(272) 評論(0)  編輯  收藏 所屬分類: JAVA

    主站蜘蛛池模板: 免费大片黄手机在线观看| 日韩成人免费在线| 久久久久亚洲Av片无码v| 曰批全过程免费视频观看免费软件| 亚洲人成色77777| 全黄A免费一级毛片| 亚洲AV无码专区日韩| 免费夜色污私人影院网站| 亚洲一区二区视频在线观看| 人人公开免费超级碰碰碰视频| 久久激情亚洲精品无码?V| 中文字幕av免费专区| 亚洲精品在线观看视频| 亚洲无砖砖区免费| 亚洲五月综合网色九月色| 免费涩涩在线视频网| 日韩精品免费一线在线观看| 国产国拍亚洲精品福利| 日韩免费高清大片在线| 亚洲午夜爱爱香蕉片| 中文字幕在线免费观看视频| 久久青青成人亚洲精品| 青青青免费国产在线视频小草| 91麻豆国产自产在线观看亚洲| 十八禁视频在线观看免费无码无遮挡骂过 | 亚洲嫩模在线观看| 国产免费AV片在线播放唯爱网| 亚洲最大无码中文字幕| 亚洲av片一区二区三区| 中文字幕日本人妻久久久免费| 亚洲国产视频网站| 国产高清不卡免费视频| 亚洲午夜电影一区二区三区| 成人爱做日本视频免费| 光棍天堂免费手机观看在线观看| 亚洲视频手机在线| 国产一级理论免费版| 国产午夜不卡AV免费| 狠狠色伊人亚洲综合网站色| 亚洲福利视频一区二区| 67194国产精品免费观看|