unknown和forward属性,input属性
首先明白ActionMapping一个实例对应了struts-config.xml文件中的一个<action>标签
forward属性:forward属性,如果配置了这个属性,那么你可以不用写action,在配置文件中配置一个空的action就可以了,那么他也可以通过这个来进行转向.
processForward这个方法:如果正常编写Action的话是不会进到这个方法里面的,这个方法就是用来处理action中forward属性的.
<action path="/login" forward="/login.jsp" ></action>
unknown属性:要.do请求才能用的,配置如下
<action path="/xxx" unknown="true" forward="/error.jsp"></action>
struts对他的处理过程:
protected ActionMapping processMapping(HttpServletRequest request,
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;
}
input属性:与异常有关