Struts2,如何将@Result类型参数定义为tiles结果

发布于 2024-12-05 13:16:06 字数 775 浏览 1 评论 0原文

我在定义 @Result 注释的“类型”参数时遇到问题

,这是我的操作注释:

@Action(value="login", 
    results=@Result(name="success",location="index.page", type="tiles" ))

其中 index.page 是我的图块定义,我如何定义“图块”实际上是图块结果?

在我使用 struts.xml 进行配置之前,我可以将

<result-types>
    <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>

我尝试的任何内容放在那里:

SEVERE: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
...
Caused by: The Result type [tiles] which is defined in the Result annotation ... 
could not be found as a result-type defined for the Struts/XWork package 
[com.action#convention-default#] - [unknown location]

i am having trouble defining 'type' parameter of @Result annotation

here is my action annotation:

@Action(value="login", 
    results=@Result(name="success",location="index.page", type="tiles" ))

where index.page is my tiles definition, how do i define that 'tiles' is actually tiles result ?

before i was using struts.xml for config, and i could just place there

<result-types>
    <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
</result-types>

whatever i try i always get:

SEVERE: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
...
Caused by: The Result type [tiles] which is defined in the Result annotation ... 
could not be found as a result-type defined for the Struts/XWork package 
[com.action#convention-default#] - [unknown location]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏日落 2024-12-12 13:16:06

这是我在基于注释的休息设置中使用的配置。您的结果类型需要包装在您用于操作的任何默认包中:

<constant name="struts.convention.default.parent.package" value="restful"/>

<package name="restful"  extends="rest-default, struts-default, json-default">
    <result-types>
        <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
        <result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
    </result-types> 

</package>

Here is the configuration I use in my annotations based rest setup. Your result types need to be wrapped in whatever default package you're using for your actions:

<constant name="struts.convention.default.parent.package" value="restful"/>

<package name="restful"  extends="rest-default, struts-default, json-default">
    <result-types>
        <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
        <result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
    </result-types> 

</package>
会发光的星星闪亮亮i 2024-12-12 13:16:06

您应该在扩展tiles-default的包中定义您的结果。

<package name="ps" extends="json-default,tiles-default">

在动作类中

@Results({ 
    @Result(name = "success", location = "feedback_management.jsp")
    ,@Result(name = "listPage", 
    type = "tiles" ,location = "table.tiles")
})

you should define your results in a package that extends tiles-default.

<package name="ps" extends="json-default,tiles-default">

and in the action class

@Results({ 
    @Result(name = "success", location = "feedback_management.jsp")
    ,@Result(name = "listPage", 
    type = "tiles" ,location = "table.tiles")
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文