1.BaseServlet
package czb.utils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
/**
* 对HttpServlet 进行扩展
*/
public abstract class BaseServlet extends HttpServlet {
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException {
// 设置post中文乱码问题
request.setCharacterEncoding("UTF-8");
// 接受用户请求的方法
String methodName = request.getParameter("metd");
if (methodName == null ||methodName.trim().equals("")) {
methodName= "execute";
}
try {
// 反射出子类的方法
Method method = this.getClass().getMethod(methodName,
HttpServletRequest.class, HttpServletResponse.class);