Spring MVC Spring Ibatis or Struts MVC Spring iBATIS uses Spring combo, and the example given by iBatis is different from ================ installation: The environment I use is mysql. After compiling the WAR file according to Readme, the Tomcat4 creates a database table and inserts data according to two files. It will find that there is no thing below Web-INF, in fact, all servlets are packaged to JPETStore. Jar is in it. For the trial, I removed this JAR package and recompiled it with Eclipse. -------------- Use Spring comes with JPETStore, MVC uses two, Spring and Struts, the default MVC framework is Spring. If you want to use struts, configure web.xml, change the * .do mapping to Struts ActionServlet (changed to the partial part of the comment) The data persistence layer is iBATIS.
Note that all JSP pages are placed under Web-INF, access through servlet, so you can't directly access JSP pages directly through the address, improve security. First analyze the part of the Struts MVC. The index.html homepage gives links to Shop / INDEX.DO. Struts-config.xml
The following is based on the process from the Access Home to Login to complete the specific process. (Using Struts's MVC frame) ==== index.jsp === TAGLIB JSTL. The page consists of 4 parts, including includetop.jsp, this page, includebanner.jsp, includebottom.jsp. Use Taglib to get user data in the session in the includetop.jsp.jsp. Depending on whether there is data to display the corresponding content. === Signonform.jsp === Login is available in includetop.jsp, defined as shown below
(Forward in FORM is not logged in or permissions, save the current path, prompt login, get the page after logging in to return the page, for example: Enter shop / editaccountform.do in the address bar without logging in, will Turn to the login page, automatically return Shop / EditaccountForm.do after logging in. This feature is controlled by the public abstract class securebaseaction extends baseAction, verification of permissions in the Execute method in this action) --------- ------ GetPetStore () is defined in the baseAction, returns an org.springframework.samples.jpetstore.domain.logic.petstoreFacade, which is an interface. Define private petstorefacade petstore in baseAction; followed by a public void setservlet (ActionServlet ActionServlet), which is overloaded, and Struts automatically performs this method when creating an Action instance. (See struts api doc) (there is a problem, I do not know whether this petStore is thread-safe.) SetServlet to get PetStoreFacade corresponding implementation ServletContext servletContext = actionServlet.getServletContext by spring (); WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext (servletContext); THIS.PETSTORE = (PetStoreFacade) Wac.getBean ("PetStore"); to initialize PetStore.