📄 baseaction.java
字号:
package com.cvicse.myssh.struts.action.base;
import javax.servlet.ServletContext;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionServlet;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import com.cvicse.myssh.spring.service.ILoginService;
//不用加Listener时可以用这种方法获取配置文件及配置文件中的属性
public class BaseAction extends Action {
private ILoginService iloginService;
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
WebApplicationContext wac =
WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
System.out.println(wac);
this.iloginService = (ILoginService) wac.getBean("loginManager");
}
public ILoginService getIloginService() {
return iloginService;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -