在web.xml的<servlet>标签中增添
<init-param>
<param-name>XXX</param-name>
<param-value>XXX</param-value>
</init-param>
public void init() throws ServletException {
// Put your code here
this.setUsername(this.getInitParameter("username"));
this.setPassword(this.getInitParameter("password"));
}