struts1.x+spring不使用代理,直接写死的方法获得logic

package org.chuck.web.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionServlet;
import org.chuck.logic.WeekReportLogic;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public abstract class WeekReportBaseAction extends Action {

	protected WeekReportLogic weekReportLogic;

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * cn.com.dragontec.app.common.web.action.BaseAction#doAction(org.apache
	 * .struts.action.ActionMapping, org.apache.struts.action.ActionForm,
	 * javax.servlet.http.HttpServletRequest,
	 * javax.servlet.http.HttpServletResponse)
	 */
	protected abstract ActionForward doAction(ActionMapping actionMapping,
			ActionForm actionForm, HttpServletRequest request,
			HttpServletResponse response) throws Exception;

	
	@Override
	public void setServlet(ActionServlet actionServlet) {

		super.setServlet(servlet);
		if (actionServlet != null) {
			AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");
			weekReportLogic = (WeekReportLogic) applicationContext
					.getBean("weekReportLogic");
		}
	}
	
	public ActionForward execute(ActionMapping actionMapping,
			ActionForm actionForm, HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		
		return doAction(actionMapping, actionForm, request, response);
	}
}

你可能感兴趣的:(apache,spring,Web,struts,servlet)