为包设置默认结果类型
Set a default result type for a package
我正在阅读关于 result
s here 的 struts 指南。
它说:
Each package may set a default result type to be used if none is specified in a result element. If one package extends another, the "child" package can set its own default result, or inherit one from the parent.
然后显示以下代码:
public Result runAction() {
ServletDispatcherResult result = new ServletDispatcherResult();
result.setLocation("input-form.jsp");
return result;
}
但我无法理解此代码如何为包中的操作设置默认结果类型。谁能给我解释一下?
该代码不会设置默认结果类型。要设置默认结果类型,您可以使用代码
PackageConfig.Builder packageConfig = new PackageConfig.Builder(packageName).defaultResultType(resultTypeName);
对于 XmlConfigurationProvider
,包名称和结果类型名称均由 name
属性定义。 result-type
标签也有属性 default
。它有一个字符串 true
或任何其他用于确定包的默认结果类型的值。
我正在阅读关于 result
s here 的 struts 指南。
它说:
Each package may set a default result type to be used if none is specified in a result element. If one package extends another, the "child" package can set its own default result, or inherit one from the parent.
然后显示以下代码:
public Result runAction() {
ServletDispatcherResult result = new ServletDispatcherResult();
result.setLocation("input-form.jsp");
return result;
}
但我无法理解此代码如何为包中的操作设置默认结果类型。谁能给我解释一下?
该代码不会设置默认结果类型。要设置默认结果类型,您可以使用代码
PackageConfig.Builder packageConfig = new PackageConfig.Builder(packageName).defaultResultType(resultTypeName);
对于 XmlConfigurationProvider
,包名称和结果类型名称均由 name
属性定义。 result-type
标签也有属性 default
。它有一个字符串 true
或任何其他用于确定包的默认结果类型的值。