两种
一。通过表单或者url传参command,servlet内用switch(command)来选择相应的处理方法
二。通过配置web.xml,得到servletPath,得到方法名,通过反射执行对应方法
第一步: web.xml的配置
*.do
第二步:作为controler的servlet的书写
String servletName = request.getServletPath();// /******.do
String command = servletName.substring(1, servletName.length() - 3);//去除.do和“/"字符
try {
Method method = this.getClass().getDeclaredMethod(command, HttpServletRequest.class, HttpServletResponse.class);
method.invoke(this, request, response);
} catch (NoSuchMethodException ex) {
} catch (SecurityException ex) {
} catch (Illegal