• <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

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

            web.xml中l(wèi)oad-on-startup標(biāo)簽的含義

            servlet的配置當(dāng)中,<load-on-startup>6</load-on-startup>的含義是:

            標(biāo)記容器是否在啟動的時候就加載這個servlet

            當(dāng)值為0或者大于0時,表示容器在應(yīng)用啟動時就加載這個servlet

            當(dāng)是一個負(fù)數(shù)時或者沒有指定時,則指示容器在該servlet被選擇時才加載。

            正數(shù)的值越小,啟動該servlet的優(yōu)先級越高。


            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.

            我以配置數(shù)據(jù)庫連接為例。

            1web.xml文件的內(nèi)容如下

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

            2,配置連接參數(shù)的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("
            數(shù)據(jù)配置設(shè)置完成!"+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內(nèi)容如下:

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

             

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

            久久精品国产亚洲AV久| 影音先锋女人AV鲁色资源网久久| 国产人久久人人人人爽| 欧美激情精品久久久久| 品成人欧美大片久久国产欧美...| 国产成人无码精品久久久久免费| 精品久久人人妻人人做精品| 久久亚洲AV无码精品色午夜| 精品永久久福利一区二区| 国产巨作麻豆欧美亚洲综合久久 | 亚洲中文字幕无码久久精品1 | 久久99国产综合精品免费| 亚洲国产精品人久久| 青青草原综合久久大伊人| 成人久久精品一区二区三区| 一本色道久久88综合日韩精品 | 国产精品一区二区久久| 偷窥少妇久久久久久久久| 伊人久久大香线蕉精品| 少妇久久久久久被弄高潮| 久久久噜噜噜久久| 久久精品黄AA片一区二区三区| 欧美与黑人午夜性猛交久久久 | 久久中文字幕无码专区 | 99久久精品国产一区二区三区 | 午夜精品久久久久久久| 久久综合伊人77777麻豆| 99久久国产综合精品成人影院| 国产亚洲欧美精品久久久 | 精品国产VA久久久久久久冰| 久久精品桃花综合| 亚洲国产成人精品91久久久 | 国产一区二区久久久| 亚洲国产成人精品无码久久久久久综合| AV无码久久久久不卡网站下载| 狠狠色婷婷久久综合频道日韩| 亚洲欧美成人久久综合中文网 | 国产精品禁18久久久夂久| 亚洲AV无码久久精品蜜桃| 99精品久久久久久久婷婷| 久久精品日日躁夜夜躁欧美|