String file = this.getInitParameter(“file”);
System.out.println(file);
String realPath = this.getServletContext().getRealPath(file);
System.out.println(realPath);
Properties p = new Properties();
p.load(new FileInputStream(realPath));
String username = p.getProperty(“username”);
String password = p.getProperty(“password”);
System.out.println(username,password);
Servlet 就是一个类,它继承了httpservlet, 要求实现它几个方法
doGet()、doPost()、
由容器对其进行实例化,tomcat容器
生命周期:实例化、初始化、doGet()、doPost()、destroy销毁
servlet配置:在web.xml中进行配置,在myeclipse中不需要手工配置,servlet-mapping对应一个映射
servlet就是一个控制层
本文介绍Servlet的基本概念,包括其实现方法如doGet()和doPost(),生命周期阶段如实例化、初始化、请求处理及销毁,以及如何通过web.xml进行配置。
678

被折叠的 条评论
为什么被折叠?



