package www.test.web.servlet;

import java.io.IOException;
import java.lang.reflect.Method; import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@SuppressWarnings("all")
public class BaseServlet extends HttpServlet { @Override
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//解决乱码问题
resp.setContentType("text/html;charset=UTF-8"); try {
// 1 获得请求的method方法
String methodName = req.getParameter("method");
// 2获得当前被访问的对象的字节码对象
Class clazz = this.getClass(); //ProductServlet.class --- UserServlet.class
// 3 获取当前字节码对象中指定的方法
Method method = clazz.getMethod(methodName,HttpServletRequest.class,HttpServletResponse.class);
// 4 执行相应的方法
method.invoke(this,req,resp);
} catch (Exception e) {
e.printStackTrace();
}
}
}

最新文章

  1. iOS系列文章
  2. unity如何显示血条(不使用NGUI)
  3. Web API应用架构在Winform混合框架中的应用(5)--系统级别字典和公司级别字典并存的处理方式
  4. C 文件读写2
  5. LightOJ1051 Good or Bad(DP)
  6. Java基础(61):Java单步调试(转)
  7. 微信ios版6.2更新 聊天记录迁移更快捷朋友圈可翻译
  8. Linux江湖01:玩转Linux系统的方法论 (转载)
  9. perl 访问网站一些useragent的设置
  10. 原生AJAX基础讲解及兼容处理
  11. Jsp页面用table表格来让文字和文本框对齐
  12. Leetcode_102_Binary Tree Level Order Traversal
  13. 关于Python深浅拷贝
  14. EAP-MD5计算方法
  15. nodejs 中的一些方法
  16. P3830 [SHOI2012]随机树 题解
  17. ELK+MySQL出现大量重复记录问题处理
  18. delphi Tdxribbon 设置背景和skin 皮肤
  19. HDU 6390 GuGuFishtion
  20. spring boot 学习(四)Druid连接池的使用配置

热门文章

  1. .net Reflection(反射)- 二
  2. .netcore项目部署IIS问题
  3. 1、认识Socket
  4. linux 虚拟机 安装 php-7.0.2
  5. 洛谷P4517 [JSOI2018]防御网络(dp)
  6. 深度剖析MQTT协议的整个通信流程
  7. jquery实现下拉菜单
  8. windows xp 环境下 Oracle8i 双击安装文件无反应的解决办法
  9. 一个数字从后向前输入每一位数字,Camel和Pascal命名规范,IsValid()
  10. 洛谷 P1272 重建道路