package com.cjq.servlet;
import java.util.Map;
public class ActionMapping {
private String path;
private Object type;
private Map forwardMap;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public Object getType() {
return type;
}
public void setType(Object type) {
this.type = type;
}
public Map getForwardMap() {
return forwardMap;
}
public void setForwardMap(Map forwardMap) {
this.forwardMap = forwardMap;
}
}
/**
* <p>Select the mapping used to process theselection path for this request
* If no mapping can be identified, createan error response and return
* <code>null</code>.</p>
*
* @param request The servlet request weare processing
* @param response The servlet response weare creating
* @param path The portion of the requestURI for selecting a mapping
*
* @exception IOException if an input/outputerror occurs
*/
protectedActionMapping processMapping(HttpServletRequestrequest,
HttpServletResponse response,
String path)
throws IOException {
// Is there a mapping for this path?
ActionMapping mapping = (ActionMapping)
moduleConfig.findActionConfig(path);
// If a mapping is found, put it in the request and return it
if (mapping != null) {
request.setAttribute(Globals.MAPPING_KEY, mapping);
return (mapping);
}
// Locate the mapping for unknown paths (if any)
ActionConfig configs[] = moduleConfig.findActionConfigs();
for (int i = 0; i < configs.length; i++) {
if (configs[i].getUnknown()) {
mapping = (ActionMapping)configs[i];
request.setAttribute(Globals.MAPPING_KEY, mapping);
return (mapping);
}
}
// No mapping can be found to process this request
String msg = getInternal().getMessage("processInvalid");
log.error(msg + " " + path);
response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
return null;
}
ActionMapping mapping =(ActionMapping) moduleConfig.findActionConfig(path);
if (mapping != null) {
request.setAttribute(Globals.MAPPING_KEY, mapping);
return (mapping);
}
// Locate the mapping for unknownpaths (if any)
ActionConfig configs[] = moduleConfigfindActionConfigs();
for (int i = 0; i < configslength; i++) {
if (configs[i].getUnknown()) {
mapping = (ActionMapping)configs[i];
request.setAttribute(Globals.MAPPING_KEY, mapping);
return (mapping);
}
}
// No mapping can be found to process this request
String msg = getInternal().getMessage("processInvalid");
log.error(msg + " " + path);
response.sendError(HttpServletResponse.SC_NOT_FOUND, msg);
return null;
/**
* <p>Retrieve and return the <code>ActionForm</code> associatedwith
* this mapping, creating and retaining oneif necessary. If there is no
* <code>ActionForm</code> associated with this mapping,return
* <code>null</code>.</p>
*
* @param request The servlet request weare processing
* @param response The servlet response weare creating
* @param mapping The mapping we are using
*/
protectedActionForm processActionForm(HttpServletRequestrequest,
HttpServletResponse response,
ActionMapping mapping) {
// Create (if necessary) a form bean to use
ActionForm instance = RequestUtilscreateActionForm
(request, mapping, moduleConfig, servlet);
if (instance == null) {
return (null);
}
// Store the new instance in the appropriate scope
if (log.isDebugEnabled()) {
log.debug(" Storing ActionForm bean instance in scope '" +
mapping.getScope() + "' under attribute key '" +
mapping.getAttribute() + "'");
}
if ("request".equals(mapping.getScope())) {
request.setAttribute(mapping.getAttribute(), instance);
} else {
HttpSession session =requestgetSession();
session.setAttribute(mapping.getAttribute(), instance);
}
return (instance);
}
// Create (if necessary) a formbean to use
ActionForm instance = RequestUtils.createActionForm
(request, mapping, moduleConfig, servlet);
if (instance == null) {
return (null);
}
publicstaticActionForm createActionForm(
HttpServletRequest request,
ActionMapping mapping,
ModuleConfig moduleConfig,
ActionServlet servlet) {
// Is there a form bean associated with this mapping?
String attribute = mappinggetAttribute();
if (attribute == null) {
return (null);
}
// Look up the form bean configuration information to use
String name = mapping.getName();
FormBeanConfig config =moduleConfigfindFormBeanConfig(name);
if (config == null) {
log.warn("No FormBeanConfig found under '"+ name + "'");
return (null);
}
ActionForm instance = lookupActionForm(request,attribute, mappinggetScope());
// Can we recycle the existing form bean instance (if there is one)?
try {
if (instance != null && canReuseActionForm(instance,config)) {
return (instance);
}
} catch(ClassNotFoundException e) {
log.error(servlet.getInternal().getMessage("formBean",config.getType()), e);
return (null);
}
return createActionForm(config,servlet);
}
<form-beans>
<form-bean name="loginForm" type=".struts.LoginActionForm"/>
</form-beans>
if ("request".equals(scope)){
instance = (ActionForm)request.getAttribute(attribute);
} else {
session = request.getSession();
instance = (ActionForm)session.getAttribute(attribute);
}
if ("request".equals(mapping.getScope())){
request.setAttribute(mapping.getAttribute(), instance);
} else {
HttpSession session =request.getSession();
session.setAttribute(mapping.getAttribute(), instance);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有