本文整理汇总了Java中org.apache.struts.action.ActionServlet类的典型用法代码示例。如果您正苦于以下问题:Java ActionServlet类的具体用法?Java ActionServlet怎么用?Java ActionServlet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionServlet类属于org.apache.struts.action包,在下文中一共展示了ActionServlet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* Initialize and load our resources.
*
* @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 {
// Remember our associated configuration and servlet
this.config = config;
this.servlet = servlet;
// Load our database from persistent storage
try {
this.initResources();
servlet.getServletContext().setAttribute(VALIDATOR_KEY + config.getPrefix(),
resources);
servlet.getServletContext().setAttribute(STOP_ON_ERROR_KEY + '.' + config.getPrefix(),
(this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new UnavailableException("Cannot load a validator resource from '" + pathnames + "'");
}
}
示例2: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* <p>Receive notification that the specified module is being
* started up.</p>
*
* @param servlet ActionServlet that is managing all the modules
* in this web application.
* @param moduleConfig ModuleConfig for the module with which
* this plugin is associated.
*
* @exception ServletException if this <code>PlugIn</code> cannot
* be successfully initialized.
*/
public void init(ActionServlet servlet, ModuleConfig moduleConfig)
throws ServletException {
// Create factory config object
DefinitionsFactoryConfig factoryConfig =
readFactoryConfig(servlet, moduleConfig);
// Set the module name in the config. This name will be used to compute
// the name under which the factory is stored.
factoryConfig.setFactoryName(moduleConfig.getPrefix());
// Set RequestProcessor class
this.initRequestProcessorClass(moduleConfig);
this.initTilesUtil();
this.initDefinitionsFactory(servlet.getServletContext(), moduleConfig, factoryConfig);
}
示例3: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
public void init(ActionServlet actionServlet,ModuleConfig moduleConfig) throws ServletException{
super.init(actionServlet,moduleConfig);
try{
// Inicializamos implementacion de firma (almacenamos en contexto)
if (StringUtils.isEmpty((String) getServletContext().getAttribute(Constants.IMPLEMENTACION_FIRMA_KEY))){
getServletContext().setAttribute(Constants.IMPLEMENTACION_FIRMA_KEY,PluginFactory.getInstance().getPluginFirma().getProveedor());
}
// Inicializamos si se obligaran los avisos a los expedientes generados desde modulo de gestion expedientes
ConfiguracionDelegate config = DelegateUtil.getConfiguracionDelegate();
Properties configProps = config.obtenerConfiguracion();
getServletContext().setAttribute(Constants.GESTIONEXPEDIENTES_OBLIGATORIOAVISOS,StringUtils.defaultString(configProps.getProperty("gestionExpedientes.avisosObligatorios"), "false"));
}catch (Exception ex){
log.error("Error obteniendo implementacion firma",ex);
throw new ServletException(ex);
}
}
示例4: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
public void init(ActionServlet actionServlet,ModuleConfig moduleConfig) throws ServletException{
super.init(actionServlet,moduleConfig);
String obligAvisosNotif;
String contextoSistra;
try {
// Indicamos si son obligatorias los avisos para las notificaciones
ConfiguracionDelegate config = DelegateUtil.getConfiguracionDelegate();
Properties configProps = config.obtenerConfiguracion();
contextoSistra = StringUtils.defaultString(configProps.getProperty("sistra.contextoRaiz"), "");
obligAvisosNotif = StringUtils.defaultString(configProps.getProperty("sistra.avisoObligatorioNotificaciones"), "false");
}catch (Exception ex){
log.error("Error obteniendo obligatoriedad avisos para notificaciones (ponemos a false): " + ex.getMessage(),ex);
obligAvisosNotif = "false";
contextoSistra = "";
}
getServletContext().setAttribute(Constants.AVISOS_OBLIGATORIOS_NOTIFICACIONES,obligAvisosNotif);
getServletContext().setAttribute(Constants.CONTEXTO_RAIZ, contextoSistra);
}
示例5: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* Initialize and load our resources.
*
* @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 {
// Remember our associated configuration and servlet
this.config = config;
this.servlet = servlet;
// Load our database from persistent storage
try {
this.initResources();
servlet.getServletContext().setAttribute(VALIDATOR_KEY
+ config.getPrefix(), resources);
servlet.getServletContext().setAttribute(STOP_ON_ERROR_KEY + '.'
+ config.getPrefix(),
(this.stopOnFirstError ? Boolean.TRUE : Boolean.FALSE));
} catch (Exception e) {
log.error(e.getMessage(), e);
throw new UnavailableException(
"Cannot load a validator resource from '" + pathnames + "'");
}
}
示例6: createActionForm
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* <p>Create and return an <code>ActionForm</code> instance appropriate to
* the information in <code>config</code>.</p>
*
* <p>Does not perform any checks to see if an existing ActionForm exists
* which could be reused.</p>
*
* @param config The configuration for the Form bean which is to be
* created.
* @param servlet The action servlet
* @return ActionForm instance associated with this request
*/
public static ActionForm createActionForm(FormBeanConfig config,
ActionServlet servlet) {
if (config == null) {
return (null);
}
ActionForm instance = null;
// Create and return a new form bean instance
try {
instance = config.createActionForm(servlet);
if (log.isDebugEnabled()) {
log.debug(" Creating new "
+ (config.getDynamic() ? "DynaActionForm" : "ActionForm")
+ " instance of type '" + config.getType() + "'");
log.trace(" --> " + instance);
}
} catch (Throwable t) {
log.error(servlet.getInternal().getMessage("formBean",
config.getType()), t);
}
return (instance);
}
示例7: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* <p>Receive notification that the specified module is being
* started up.</p>
*
* @param servlet ActionServlet that is managing all the modules
* in this web application.
* @param moduleConfig ModuleConfig for the module with which
* this plugin is associated.
*
* @exception ServletException if this <code>PlugIn</code> cannot
* be successfully initialized.
*/
public void init(ActionServlet servlet, ModuleConfig moduleConfig)
throws ServletException {
// Create factory config object
DefinitionsFactoryConfig factoryConfig =
readFactoryConfig(servlet, moduleConfig);
// Set the module name in the config. This name will be used to compute
// the name under which the factory is stored.
factoryConfig.setFactoryName(moduleConfig.getPrefix());
// Set RequestProcessor class
this.initRequestProcessorClass(moduleConfig);
this.initTilesUtil();
this.initDefinitionsFactory(servlet.getServletContext(), moduleConfig, factoryConfig);
}
示例8: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
@Override
public void init(final ActionServlet servlet, final ModuleConfig config) throws ServletException {
super.init(servlet, config);
// Load the properties file
final Properties properties = new Properties();
try {
properties.load(getClass().getResourceAsStream("/cyclos.properties"));
} catch (final IOException e) {
throw new ServletException("Error reading cyclos.properties");
}
final boolean httpEnabled = "true".equalsIgnoreCase(properties.getProperty("cyclos.security.enable", "false"));
setEnable(String.valueOf(httpEnabled));
setHttpPort(properties.getProperty("cyclos.security.port.http", "80"));
setHttpsPort(properties.getProperty("cyclos.security.port.https", "443"));
setAddSession("false");
servlet.getServletContext().setAttribute("cyclos.httpEnabled", httpEnabled);
}
示例9: init
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* Create the ActionServlet's WebApplicationContext.
*/
public final void init(ActionServlet actionServlet, ModuleConfig moduleConfig) throws ServletException {
long startTime = System.currentTimeMillis();
if (logger.isInfoEnabled()) {
logger.info("ContextLoaderPlugIn for Struts ActionServlet '" + actionServlet.getServletName() +
", module '" + moduleConfig.getPrefix() + "': initialization started");
}
this.actionServlet = actionServlet;
this.moduleConfig = moduleConfig;
try {
this.webApplicationContext = initWebApplicationContext();
onInit();
}
catch (RuntimeException ex) {
logger.error("Context initialization failed", ex);
throw ex;
}
if (logger.isInfoEnabled()) {
long elapsedTime = System.currentTimeMillis() - startTime;
logger.info("ContextLoaderPlugIn for Struts ActionServlet '" + actionServlet.getServletName() +
"', module '" + moduleConfig.getPrefix() + "': initialization completed in " + elapsedTime + " ms");
}
}
示例10: getWebApplicationContext
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* Fetch ContextLoaderPlugIn's WebApplicationContext from the ServletContext.
* <p>Checks for a module-specific context first, falling back to the
* context for the default module else.
* @param actionServlet the associated ActionServlet
* @param moduleConfig the associated ModuleConfig (can be {@code null})
* @return the WebApplicationContext, or {@code null} if none
* @see ContextLoaderPlugIn#SERVLET_CONTEXT_PREFIX
*/
public static WebApplicationContext getWebApplicationContext(
ActionServlet actionServlet, ModuleConfig moduleConfig) {
WebApplicationContext wac = null;
String modulePrefix = null;
// Try module-specific attribute.
if (moduleConfig != null) {
modulePrefix = moduleConfig.getPrefix();
wac = (WebApplicationContext) actionServlet.getServletContext().getAttribute(
ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX + modulePrefix);
}
// If not found, try attribute for default module.
if (wac == null && !"".equals(modulePrefix)) {
wac = (WebApplicationContext) actionServlet.getServletContext().getAttribute(
ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX);
}
return wac;
}
示例11: actionSupportWithContextLoaderPlugIn
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
@Test
@SuppressWarnings("serial")
public void actionSupportWithContextLoaderPlugIn() throws ServletException {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.addMessage("test", Locale.getDefault(), "testmessage");
final ServletContext servletContext = new MockServletContext();
wac.setServletContext(servletContext);
wac.refresh();
servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);
ActionServlet actionServlet = new ActionServlet() {
@Override
public ServletContext getServletContext() {
return servletContext;
}
};
ActionSupport action = new ActionSupport() {
};
action.setServlet(actionServlet);
assertEquals(wac, action.getWebApplicationContext());
assertEquals(servletContext, action.getServletContext());
assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
action.setServlet(null);
}
示例12: actionSupportWithRootContext
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
@Test
@SuppressWarnings("serial")
public void actionSupportWithRootContext() throws ServletException {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.addMessage("test", Locale.getDefault(), "testmessage");
final ServletContext servletContext = new MockServletContext();
wac.setServletContext(servletContext);
wac.refresh();
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
ActionServlet actionServlet = new ActionServlet() {
@Override
public ServletContext getServletContext() {
return servletContext;
}
};
ActionSupport action = new ActionSupport() {
};
action.setServlet(actionServlet);
assertEquals(wac, action.getWebApplicationContext());
assertEquals(servletContext, action.getServletContext());
assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
action.setServlet(null);
}
示例13: dispatchActionSupportWithContextLoaderPlugIn
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
@Test
@SuppressWarnings("serial")
public void dispatchActionSupportWithContextLoaderPlugIn() throws ServletException {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.addMessage("test", Locale.getDefault(), "testmessage");
final ServletContext servletContext = new MockServletContext();
wac.setServletContext(servletContext);
wac.refresh();
servletContext.setAttribute(ContextLoaderPlugIn.SERVLET_CONTEXT_PREFIX, wac);
ActionServlet actionServlet = new ActionServlet() {
@Override
public ServletContext getServletContext() {
return servletContext;
}
};
DispatchActionSupport action = new DispatchActionSupport() {
};
action.setServlet(actionServlet);
assertEquals(wac, action.getWebApplicationContext());
assertEquals(servletContext, action.getServletContext());
assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
action.setServlet(null);
}
示例14: dispatchActionSupportWithRootContext
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
@Test
@SuppressWarnings("serial")
public void dispatchActionSupportWithRootContext() throws ServletException {
StaticWebApplicationContext wac = new StaticWebApplicationContext();
wac.addMessage("test", Locale.getDefault(), "testmessage");
final ServletContext servletContext = new MockServletContext();
wac.setServletContext(servletContext);
wac.refresh();
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, wac);
ActionServlet actionServlet = new ActionServlet() {
@Override
public ServletContext getServletContext() {
return servletContext;
}
};
DispatchActionSupport action = new DispatchActionSupport() {
};
action.setServlet(actionServlet);
assertEquals(wac, action.getWebApplicationContext());
assertEquals(servletContext, action.getServletContext());
assertEquals("testmessage", action.getMessageSourceAccessor().getMessage("test"));
action.setServlet(null);
}
示例15: testProcessMapping
import org.apache.struts.action.ActionServlet; //导入依赖的package包/类
/**
* @throws Exception
*/
public void testProcessMapping() throws Exception {
S2ActionMapping mapping = new S2ActionMapping();
mapping.setPath("/aaa/bbb");
mapping.setComponentDef(getComponentDef("aaa_bbbAction"));
S2ExecuteConfig executeConfig = new S2ExecuteConfig();
executeConfig.setMethod(getClass().getMethod("getClass"));
mapping.addExecuteConfig(executeConfig);
S2RequestProcessor processor = new S2RequestProcessor();
S2ModuleConfig moduleConfig = new S2ModuleConfig("");
moduleConfig.addActionConfig(mapping);
processor.init(new ActionServlet(), moduleConfig);
ActionMapping am = processor.processMapping(getRequest(),
getResponse(), "/aaa/bbb");
assertNotNull(am);
assertSame(am, mapping);
assertNotNull(getRequest().getAttribute(Globals.MAPPING_KEY));
}