📄 baseaction.java
字号:
package com.dark.nethd.web.action;
import javax.servlet.ServletContext;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionServlet;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.dark.nethd.business.IFilesInfoService;
import com.dark.nethd.business.IUserInfoService;
/*
* 该类拓展了Action类并且作为各个模块的命令类(既Action)的基类,
* 里面的execute方法通过反射机制获得其各个子类中调用的方法名
*/
public class BaseAction extends Action {
private ApplicationContext context = null;
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
context = WebApplicationContextUtils
.getRequiredWebApplicationContext(servletContext);
}
protected ApplicationContext getContext() {
return context;
}
protected IUserInfoService userInfoService;
public IUserInfoService getUserInfoService() {
return (IUserInfoService) getContext().getBean("userInfoService");
}
public void setUserInfoService(IUserInfoService userInfoService) {
this.userInfoService = userInfoService;
}
protected IFilesInfoService fliesInfoService;
public IFilesInfoService getFliesInfoService() {
return (IFilesInfoService) getContext().getBean("fliesInfoService");
}
public void setFliesInfoService(IFilesInfoService fliesInfoService) {
this.fliesInfoService = fliesInfoService;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -