struts1.2 Demo

struts1.2-demo是一个我仿写jpetstore的对未登陆的处理。比较安全。对一些操作的限制。还有一些不登陆也可以的操作。经典。。。。。

public abstract class BaseAction extends Action {

  private PetStoreFacade petStore;

 public void setServlet(ActionServlet actionServlet) {
  super.setServlet(actionServlet);
  if (actionServlet != null) {
   ServletContext servletContext = actionServlet.getServletContext();
   WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
   this.petStore = (PetStoreFacade) wac.getBean("petStore");
  }
 }

 protected PetStoreFacade getPetStore() {
  return petStore;
 }

与spring2.5集成以后用WebApplicationContextUtils来获取WebApplicationContext

你可能感兴趣的:(struts1.2 Demo)