Struts2.5从struts.xml获取Struts常量自定义结果

时间:2016-07-27 18:21:10

标签: java struts2

我为Struts2编写了一个自定义结果,想知道访问struts.xml中<constants>的正确方法吗?我试图搜索Struts的文档,到目前为止已经空了。

我试图在Struts文档上找到用于编写自定义结果类型的页面,但我无法找到它。以下是关于结果类型的页面,但它对我想要实现的目标毫无帮助。

https://struts.apache.org/docs/result-types.html

1 个答案:

答案 0 :(得分:2)

使用com.opensymphony.xwork2.inject.Inject注释注入它。

在自定义结果中:

@Inject(value = "custom.const.some")
private String some;

在struts.xml中:

<constant name="custom.const.some" value="constant_for_custom_result" />
相关问题