学习的另一种Servlet实现。
来源:互联网 发布:求数组最大值和最小值 编辑:程序博客网 时间:2024/05/01 09:36
这是一种Servlet另一种实现方式,不过我想应该有更好的实习,当作学习研究。package com.Root.beas;import java.io.IOException;import java.io.PrintWriter;import java.lang.reflect.Method;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.Root.Book.Book;public class BaseServlet extends HttpServlet {public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {String className = request.getParameter("className");String methodName = request.getParameter("method");try{Class class1 = Class.forName(className);Method method = class1.getDeclaredMethod(methodName, HttpServletRequest.class,HttpServletResponse.class);method.invoke(class1.newInstance(), request,response);}catch(Exception e){e.printStackTrace();}}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doGet(request, response);}}<pre name="code" class="java">package com.Root.Book;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class Book {private String Name;public String getName() {return Name;}public void setName(String name) {Name = name;}public void addBook(HttpServletRequest request, HttpServletResponse response){System.out.println("haha");System.out.println(request.getParameter("Username"));}}
<form action="BaseServlet" method = "post"> <input type="hidden" name="className" value = "com.Root.Book.Book"> <input type="hidden" name="method" value = "addBook"> <input type="text" name="Username"> <input type = "submit" value = "提交"> </form>
0 0
- 学习的另一种Servlet实现。
- JSP------Servlet的另一种形式
- 环境变量的另一种实现
- 安卓刮刮卡的另一种实现
- OpenGL字体的另一种实现---学习NeHe OpenGL
- 数据结构学习之循环队列的另一种c++实现
- Direct9学习之--------------------------实时阴影的另一种实现ShadowMap
- 二叉排序树的另一种原型实现
- Decorator的另一种实现方式
- 使用TreeView的另一种实现
- AOP的另一种实现----cglib
- 蛇形数组的另一种实现
- LRU cache的另一种实现
- 代理的另一种实现方式
- 学习工作流的另一种方法
- 学习工作流的另一种方法
- 对反射的思考——另一种抽象,另一种实现
- Cocos2d-x学习(二十二):cocos2d-x中CCScale9Sprite的另一种实现
- iOS 通知机制
- oracle 存储过程 循环游标的简单实用示例
- Git分布式代码版本控制
- firefox 浏览器安装adobe flash player
- POJ 2418 Hardwood Species(trie的串排序运用)
- 学习的另一种Servlet实现。
- IO流综合练习
- POJ 1673 EXOCENTER OF A TRIANGLE
- linux之ACL权限学习笔记
- NetworkManager 替代工具 wicd
- android开发之Service深入分析全解
- 一个人的地老天荒
- 存储过程访问其他用户表权限不足问题
- 使用WinDbg —— .NET篇 (一)