+ "', perhaps the parent package does not specify the result type?",
resultElement);
}
}
ResultTypeConfig config = packageContext
.getResultType(resultType);
if (config == null) {
throw new ConfigurationException(
"There is no result type defined for type '"
+ resultType + "' mapped with name '"
+ resultName + "'." + " Did you mean '"
+ guessResultType(resultType) + "'?",
resultElement);
}
@SuppressWarnings("deprecation")
String resultClass = config.getClazz();
// invalid result type specified in result definition
if (resultClass == null) {
throw new ConfigurationException("Result type '"
+ resultType + "' is invalid");
}
Map<String, String> resultParams = XmlHelper
.getParams(resultElement);
if (resultParams.size() == 0) // maybe we just have a body -
// therefore a default parameter
{
// if <result ...>something</result> then we add a parameter
// of 'something' as this is the most used result param
if (resultElement.getChildNodes().getLength() >= 1) {
resultParams = new LinkedHashMap<String, String>();
String paramName = config.getDefaultResultParam();
if (paramName != null) {
StringBuilder paramValue = new StringBuilder();
for (int j = 0; j < resultElement.getChildNodes()
.getLength(); j++) {
if (resultElement.getChildNodes().item(j)
.getNodeType() == Node.TEXT_NODE) {
String val = resultElement.getChildNodes()
.item(j).getNodeValue();
if (val != null) {
paramValue.append(val);
}
}
}
String val = paramValue.toString().trim();
if (val.length() > 0) {
resultParams.put(paramName, val);
}
} else {
if (LOG.isWarnEnabled()) {
LOG.warn("no default parameter defined for result of type "
+ config.getName());
}
}
}
}
// 处理resultParams
if ("redirectAction".equals(resultType)) {
String namespace = resultParams.get("namespace");
if (namespace != null) {
namespace = handleNamespace(namespace);
}
resultParams.put("namespace", namespace);
}
// create new param map, so that the result param can override
// the config param
Map<String, String> params = new LinkedHashMap<String, String>();
Map<String, String> configParams = config.getParams();
if (configParams != null) {
params.putAll(configParams);
}
params.putAll(resultParams);