赵大笨笨 2017-05-10 02:36 采纳率: 0%
浏览 2366
已采纳

getInitParameter取值为null是什么原因啊

web.xml

BookSearch
cn.test.BookList

user
test

代码
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException{
String bookName = (String) req.getParameter("bookName");
ServletContext sc = getServletContext();
String user = (String) sc.getInitParameter("user");

}
这个user一直是null
  • 写回答

3条回答 默认 最新

  • 腾域 2017-05-10 02:56
    关注

    getServletContext()获得的是 配置里的参数信息
    getServletConfig()获得的是 配置里的参数信息

    getServletContext().相当于Application
    getServletConfig().某个servlet的配置。

    另外,这种问题需要贴上配置文件。

    -- 我今天正够闲的、、、

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?