如何從context-param獲取引數?

馬克-to-win發表於2018-12-14

3.從context-param獲取:(視訊下載) (全部書籍)
馬克-to-win:用context-param存放的引數,本個web應用中的任何servlet,jsp都可以獲得。

例:1.3.1

ServletHello1.java:

package com;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
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 {
        ServletContext servletContext = getServletContext();
        String jd =  servletContext.getInitParameter(“zhangsan”);
        System.out.println(jd);
    }

詳情請見:http://www.mark-to-win.com/index.html?content=Jsp/jspUrl.html&chapter=Jsp/jsp2_web.html#GetParamWithcontext-param

相關文章