Java Web之Servlet-02 应用MVC架构实现项目

1. 获取初始化参数

1
2
3
4
5
6
7
8
9
10
<servlet>
<init-param>
<param-name>username</param-name>
<param-value>admin</param-value>
</init-param>
<init-param>
<param-name>password</param-name>
<param-value>123456</param-value>
</init-param>
</servlet>
1
2
3
在servlet的init()方法中获取初始化的值:
this.getInitParameter("username");
this.getInitParameter("password");