package com.iyunti.core; import java.io.IOException; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.sql.DataSource; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.jdbc.core.JdbcTemplate; public class Dispatcher extends Controller { private static final long serialVersionUID = 8396066198989032944L; private ServletContext servletContext = null; /** * The doGet method of the servlet. <br> * * This method is called when a form has its tag value method equals to get. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /* * ApplicationContext act = new ClassPathXmlApplicationContext( * "applicationContext.xml"); DataSource ds = (DataSource) * act.getBean("dataSource"); * * JdbcTemplate template = new JdbcTemplate(ds); String sql = * "select count(*) from T_ACCOUNT"; * * int totalRecord = template.queryForInt(sql); * * new Product().doGet(request, response); */ // Map<String, Class<?>> classMap = (Map<String, Class<?>>) // servletContext // .getAttribute("servletClassMap"); String uri = getUriString(request); // 获取要请求的servlet路径 String requestServletName = "com.iyunti.ec." + getActionString(uri); // 创建类的实例 Object obj = null; Class<?> clz = null; Method targetMethod = null; try { // 获取要使用的Servlet类 clz = Class.forName(requestServletName); if(clz.equals(null)){ logger.error("Servlet类不存在"); } obj = clz.newInstance(); // 获取Servlet类的doGet方法 targetMethod = clz.getDeclaredMethod("doGet", HttpServletRequest.class, HttpServletResponse.class); // 调用对象的方法进行处理 targetMethod.invoke(obj, request, response); } catch (Exception e) { logger.error(e.getMessage()); } loadJsp(request, response); } /** * The doPost method of the servlet. <br> * * This method is called when a form has its tag value method equals to * post. * * @param request * the request send by the client to the server * @param response * the response send by the server to the client * @throws ServletException * if an error occurred * @throws IOException * if an error occurred */ public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doGet(request, response); } }
相关推荐
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
/* ... // Tell the dispatcher to invoke its servlet and include the output dispatcher.include(request, response); } // Finally, end the HTML output out.println("</body>"); } }
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1006) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) at org.spring...
本书共分4部分,从xml、servlet、jsp和应用的角度向读者展示了java web开发中各种技术的应用,循序渐进地引导读者快速掌握java web开发。. 本书内容全面,涵盖了从事java web开发所应掌握的所有知识。在知识的讲解...
8.2 java本身的loader 52 8.3 Loader接口 53 8.4 Reloader接口 54 8.5 WebappLoader类 54 8.5.1 创建类载入器 55 8.5.2 设置repository 55 8.5.3 设置类路径 56 8.5.4 设置访问权限 56 8.5.5 开启新线程执行类的重新...
JSP網頁最後是轉譯為Servlet,從Java程式設計人員的角度來看,Servlet其實就是一個 Java類別,它實作Servlet介面,通常我們會繼承實作該介面的GenericServlet類別或HttpServlet類別。 基礎入門 如果您瞭解JSP中的...
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196) at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432) at javax.servlet.http.HttpServlet.service...
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:689) at org.springframework.web.servlet.mvc.method....
at org.apache.axis.providers.java.JavaProvider.invoke(JavaProvider.java:323) at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) at org.apache.axis.SimpleChain....
import java.lang.reflect.Method; import java.sql.*; import java.util.*; import org.junit.Test; import com.xr.dto.ManagerDTO; public class DBHelper { private Connection conn = null; { try { ...
jsp 上传图片时,把 java 代码直接改成 jsp,上传时产生 如下异常: 2012-12-31 8:59:21 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet jsp threw exception java.io....
invoke vt.调用 [in'vәuk]' ( invocation [,invәu'keiʃәn]) Iterator [java] 迭代器, 迭代程序 legal 合法的 ['li:gәl] log n.日志,记录 [lɒg] native (关键字) ?? ['neitiv] nested [java] 嵌套的 ['...
import javax.servlet.ServletResponse; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * 恶意脚本字符过滤器 *...
2011-1-8 20:34:20 org.apache.catalina.core.StandardWrapperValve invoke 严重: Servlet.service() for servlet default threw exception java.lang.IllegalStateException at org.apache.catalina.connector....
at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: java...
invoke指令 2 Servlet规范 API Servlet生命周期 异步Servlet 3 JVM 内存区域 Java堆 方法区 Java方法栈 本地方法栈 GC 代 新生代 Eden Survivor 旧生代 持久...
8.2 java本身的loader 52 8.3 Loader接口 53 8.4 Reloader接口 54 8.5 WebappLoader类 54 8.5.1 创建类载入器 55 8.5.2 设置repository 55 8.5.3 设置类路径 56 8.5.4 设置访问权限 56 8.5.5 开启新线程执行类的重新...
ProxyFactory.proxy 方法,生成接口的代理对象,直接调用方法客户端和服务器端的接口和实体类要一致,实体类必须是可以序列化的比如:定义Bean: public class DemoBean implements java.io.Serializable{ ...