1.0 Other languages |
||||
3.1 ControllerServlet |
||||
|
org.velocityweb.controller.ControllerServlet is a sub class of org.apache.velocity.servlet.VelocityServlet. ControllerServlet will call controller.initApplication() in loadConfiguration(ServletConfig config) which is initial part of VelocityServlet, and call controller.destroyApplication() in destroy() which is destroy part of servlet. In function named as handleRequest(HttpServletRequest request, HttpServletResponse response, Context context) of class ControllerServlet, the following logic will be done:
The above web request logic is very common that we need to write it every time we start a new J2EE project. As we seldom need to change it, VelocityWeb has done this part for us. To create a new J2EE project, we only need to write a sub-class of org.velocityweb.controller.ControllerServlet and overwrite function getController(). for example:
|
|||
public public class PetStoreControllerServlet extends ControllerServlet { |
||||
And this is sample index.htm, it will jump to controller servlet path after it shows.
|
||||