我无法定义@Result注释的'type'参数
这是我的动作注释:
@Action(value="login",
results=@Result(name="success",location="index.page", type="tiles" ))
其中index.page是我的tile定义,我如何定义'tiles'实际上是tile结果?
在我使用struts.xml for config之前,我可以放在那里
<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]
答案 0 :(得分:6)
以下是我在基于注释的休息设置中使用的配置。您的结果类型需要包含在您用于操作的任何默认包中:
<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>
答案 1 :(得分:0)
您应该在扩展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")
})