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

            久久亚洲国产成人精品性色| 97精品依人久久久大香线蕉97| 999久久久国产精品| 久久亚洲高清综合| 久久人人爽人人爽人人AV| 欧美伊香蕉久久综合类网站| 亚洲精品国精品久久99热| 97精品国产97久久久久久免费| 久久久国产精品网站| 国产69精品久久久久APP下载| 久久国产精品99精品国产987| 伊人久久成人成综合网222| 久久久精品午夜免费不卡| 亚洲国产精品一区二区久久hs| 久久久这里有精品中文字幕| 国产精品九九九久久九九| 久久99精品久久久大学生| 欧美激情精品久久久久久久| 99re这里只有精品热久久 | 久久精品a亚洲国产v高清不卡| 久久精品国产一区二区三区| 色欲综合久久躁天天躁蜜桃| 久久精品18| 亚洲综合久久综合激情久久| 久久精品九九亚洲精品| 亚洲欧洲久久久精品| 久久高清一级毛片| 好属妞这里只有精品久久| 麻豆亚洲AV永久无码精品久久 | 久久久久国产精品| 久久精品午夜一区二区福利| 欧洲成人午夜精品无码区久久 | 欧美久久精品一级c片片| 国产成人久久精品一区二区三区| 亚洲AV日韩AV永久无码久久| 久久经典免费视频| 青青草原综合久久大伊人| 日本精品久久久久久久久免费| 久久久久久久久久久免费精品| 久久久久国产一区二区| 久久久久久亚洲精品无码|