配置和获取Servlet初始化参数
web.xm 文件配置
a
com.web
弟弟你好
3岁了
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Servlet config=this.getServletConfig();
String a=config.getinitparam;
system.out.println(“a”) /获得指定名称的Servlet初始化参数的值
Servet 上下文初始化参数
1.配置 web.xm
5年龄
13
</web.app>
2.获取上下文作用域参数 (方法1)
public class LoadServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Servletcontext a=this.getservletContext(); //方式一
String b=a.getinitparammeter;
system.out.println(b);
3…获取上下文作用域参数(方法2)
public void init(ServletConfig config