• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            woaidongmao

            文章均收錄自他人博客,但不喜標題前加-[轉貼],因其丑陋,見諒!~
            隨筆 - 1469, 文章 - 0, 評論 - 661, 引用 - 0
            數據加載中……

            web.xml中load-on-startup標簽的含義

            servlet的配置當中,<load-on-startup>6</load-on-startup>的含義是:

            標記容器是否在啟動的時候就加載這個servlet

            當值為0或者大于0時,表示容器在應用啟動時就加載這個servlet

            當是一個負數時或者沒有指定時,則指示容器在該servlet被選擇時才加載。

            正數的值越小,啟動該servlet的優先級越高。


            Servlet   specification:

                    The   load-on-startup   element   indicates   that   this   servlet   should   be   loaded   (instantiated   and   have   its   init()   called)   on   the   startup   of   the   web   application.   The   optional   contents   of   these   element   must   be   an   integer   indicating   the   order   in   which   the   servlet   should   be   loaded.   If   the   value   is   a   negative   integer,   or   the   element   is   not   present,   the   container   is   free   to   load   the   servlet   whenever   it   chooses.     If   the   value   is   a   positive   integer   or   0,   the   container   must   load   and   initialize   the   servlet   as   the   application   is   deployed.   The   container   must   guarantee   that   servlets   marked   with   lower   integers   are   loaded   before   servlets   marked   with   higher   integers.   The   container   may   choose   the   order   of   loading   of   servlets   with   the   same   load-on-start-up   value.

            我以配置數據庫連接為例。

            1web.xml文件的內容如下

            <servlet>
                <servlet-name>LoadDBConfigServlet</servlet-name>
                <servlet-class>org.svse.action.LoadDBConfigServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
            </servlet>

            2,配置連接參數的servlet類如下:

            public class LoadDBConfigServlet extends HttpServlet {

                public void doGet(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException {

                }

                public void doPost(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException {

                }

                public void init(ServletConfig config) throws ServletException {

                    InputStream in = LoadDBConfigServlet.class
                            .getResourceAsStream("/dbconfig.properties");
                   
                    Properties dbconfig = new Properties();
                   
                    try {
                        dbconfig.load(in);
                        System.out.println("ddd"+dbconfig.getProperty("url"));
                        DBConfig.driver = dbconfig.getProperty("driver");
                        DBConfig.url = dbconfig.getProperty("url");
                        DBConfig.username = dbconfig.getProperty("username");
                        DBConfig.pwd = dbconfig.getProperty("pwd");
                        System.out.println("
            數據配置設置完成!"+DBConfig.driver);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                }

            }

            3DBConfig類如下:

            public class DBConfig {
               
                public static String driver;
                public static String url;
                public static String username;
                public static String pwd;

            }
            4
            dbconfig.properties內容如下:

            driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
            url=jdbc:sqlserver://localhost:1433;databasename=svse
            username=sa
            pwd=sa

             

            posted on 2009-08-17 17:22 肥仔 閱讀(1022) 評論(0)  編輯 收藏 引用 所屬分類: Web-后臺

            久久人人超碰精品CAOPOREN| 性色欲网站人妻丰满中文久久不卡| 国产成人香蕉久久久久| 66精品综合久久久久久久| 99久久99久久久精品齐齐| 国内精品久久久久影院网站| 久久精品亚洲欧美日韩久久| 国产成人精品久久| 91精品国产综合久久精品| 久久国产免费直播| 久久99国内精品自在现线| 久久亚洲美女精品国产精品| 97久久久久人妻精品专区| 久久久久久曰本AV免费免费| 精品久久777| 7777久久久国产精品消防器材| 久久精品www| 亚洲国产视频久久| 久久精品国产亚洲综合色| 少妇被又大又粗又爽毛片久久黑人 | 午夜久久久久久禁播电影| 97久久综合精品久久久综合| 亚洲国产精品综合久久一线| 久久国产精品成人影院| 久久综合伊人77777| 国产亚洲美女精品久久久2020| 久久99精品久久久久久齐齐| 精品无码久久久久国产| 思思久久99热只有频精品66| 久久久91人妻无码精品蜜桃HD| 国产一久久香蕉国产线看观看| 国产精品一区二区久久精品涩爱| 精品久久久久久无码中文字幕| 国产精品久久久久久搜索| 久久久久AV综合网成人| 亚洲综合伊人久久综合| 久久久久国产精品嫩草影院| 久久人与动人物a级毛片| 伊人久久大香线蕉成人| 香蕉久久永久视频| 久久99久久99精品免视看动漫|