Saturday, July 10, 2010

1.web.xml

web.xml是替servlet做設定的功能


會分別加入 
1.<servlet></servlet>
再在裡面加入
(1) <servlet-name>替servlet取的名稱</servlet-name>
(2) <servlet-class>servlet的路徑</servlet-class>


2. <servlet-mapping></servlet-mapping>
在裡面再加入
(1) <servlet-name>servlet的名稱</servlet-name>
(2) <url-pattern>替這個servlet取上url</url-pattern>


以下是上述的實際輸出程式碼
    <servlet>
       <servlet-name>MyFirstServlet</servlet-name>
       <servlet-class>servlets.MyFirstServlet</servlet-class>
   </servlet>
   <servlet-mapping>
       <servlet-name>MyFirstServlet</servlet-name>
       <url-pattern>/my_first_servlet.view</url-pattern>
   </servlet-mapping>

No comments: