struts2核心配置之Result

result作用:在struts.xml中,使用<result>元素配置result逻辑视图和物理视图之间的映射

元素属性

属性 说明 是否必须
name 指定逻辑视图的名称(Action的返回值),默认值为success
type 指定返回的视图资源的类型,不同类型代表不同的结果输出,默认值dispatcher
<action name="FirstT" class="com.test.pojo.TestAction">
            <result name="success" type="dispatcher">
                <param name="location">/success.jsp</param>
            </result>
</action>

上述配置使用了result元素的name,type,和param子元素。

<param>子元素的name属性有两个值

  location:指定逻辑视图对应的实际视图资源

  parse:指定在逻辑视图资源名中是否可以使用OGNL表达式,默认值true

上述代码可简化为:

<action name="FirstT" class="com.test.pojo.TestAction">
            <result>/success.jsp</result>
</action>

 ResultType类型及使用详解:https://www.cnblogs.com/LuckyBao/p/6010832.html

原文地址:https://www.cnblogs.com/GG-Bond/p/10514345.html