如何用ServletConfig從init-param獲取引數?
阿新 • • 發佈:2018-12-05
2.用ServletConfig從init-param獲取:
就單純獲取init-param而言,上一種和這一種方法一樣。不過ServletConfig還有很多其他的功能。見例子。
例:1.2.1
ServletHello1.java:
package com;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletHello1 extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ServletConfig c = getServletConfig();