本文整理汇总了Java中org.apache.struts.action.ActionServlet.getServletContext方法的典型用法代码示例。如果您正苦于以下问题:Java ActionServlet.getServletContext方法的具体用法?Java ActionServlet.getServletContext怎么用?Java ActionServlet.getServletContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.struts.action.ActionServlet
的用法示例。
在下文中一共展示了ActionServlet.getServletContext方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveTempDir
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
* Retrieves the temporary directory from either ActionServlet, a context
* property, or a system property, in that order.
*/
protected void retrieveTempDir(ModuleConfig moduleConfig) {
//attempt to retrieve the servlet container's temporary directory
ActionServlet servlet = getServlet();
if (servlet != null) {
//attempt to retrieve the servlet container's temporary directory
ServletContext context = servlet.getServletContext();
try {
tempDir =
(String) context.getAttribute("javax.servlet.context.tempdir");
} catch(ClassCastException cce) {
tempDir = ((File) context.getAttribute("javax.servlet.context.tempdir")).getAbsolutePath();
}
}
if (tempDir == null) {
//attempt to retrieve the temporary directory from the controller
tempDir = moduleConfig.getControllerConfig().getTempDir();
if (tempDir == null) {
//default to system-wide tempdir
tempDir = System.getProperty("java.io.tmpdir");
log.debug(
"DiskMultipartRequestHandler.handleRequest(): "
+ "defaulting to java.io.tmpdir directory \""
+ tempDir);
}
}
}
示例2: setServlet
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
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");
}
}
示例3: setServlet
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
WebApplicationContext wac =
WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
}
示例4: setServlet
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
public void setServlet(ActionServlet actionServlet) {
super.setServlet(actionServlet);
ServletContext servletContext = actionServlet.getServletContext();
WebApplicationContext wac =
WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
}
示例5: init
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
* Intializer. Instantiates a new object and adds it to the application context by key
*
* @param servlet The ActionServlet for our application
* @param config The ModuleConfig for our owning module
* @throws ServletException if we cannot configure ourselves correctly
*/
public void init(ActionServlet servlet, ModuleConfig config)
throws ServletException {
this.servlet = servlet;
try {
ServletContext servletContext = servlet.getServletContext();
SpringObjectLocatorImpl.applicationContext=WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
} catch (Exception e) {
throw new ServletException("Could not initalize SpringObjectLocatorImpl.applicationContext",e);
}
}
示例6: init
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
* The init method is called when this plugin is initialized
* <P>
* @param actionServlet The struts ActionServlet
* @param moduleConfig The struts ModuleConfig
*/
public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
throws ServletException
{
// Retrieve the ServletContext
ServletContext ctx = actionServlet.getServletContext();
// The Quartz Scheduler
Scheduler scheduler = null;
// Retrieve the factory from the ServletContext.
// It will be put there by the Quartz Servlet
StdSchedulerFactory factory = (StdSchedulerFactory)
ctx.getAttribute(QuartzInitializerServlet.QUARTZ_FACTORY_KEY);
try
{
// Retrieve the scheduler from the factory
scheduler = factory.getScheduler();
// Start the scheduler in case, it isn't started yet
if (startOnLoad != null &&
startOnLoad.equals(Boolean.TRUE.toString()))
{
scheduler.start();
}
}
catch (Exception e)
{
logger.error("Error setting up scheduler", e);
}
sm_scheduler = scheduler;
}
示例7: init
import org.apache.struts.action.ActionServlet; //导入方法依赖的package包/类
/**
* The init method is called when this plugin is initialized
* <P>
* @param actionServlet The struts ActionServlet
* @param moduleConfig The struts ModuleConfig
*/
public void init(ActionServlet actionServlet, ModuleConfig moduleConfig)
throws ServletException
{
// Retrieve the ServletContext
ServletContext ctx = actionServlet.getServletContext();
// The Quartz Scheduler
Scheduler scheduler = null;
// Retrieve the factory from the ServletContext.
// It will be put there by the Quartz Servlet
StdSchedulerFactory factory = (StdSchedulerFactory)
ctx.getAttribute(QuartzInitializerServlet.QUARTZ_FACTORY_KEY);
try
{
// Retrieve the scheduler from the factory
scheduler = factory.getScheduler();
// Start the scheduler in case, it isn't started yet
if (startOnLoad != null &&
startOnLoad.equals(Boolean.TRUE.toString()))
{
scheduler.start();
}
}
catch (Exception e)
{
logger.error("Error setting up scheduler", e);
}
sm_scheduler = scheduler;
}