【发布时间】:2012-08-10 16:09:34
【问题描述】:
我的问题是:如果使用struts2-jquery-plugin+struts2-json-plugin,我可以定义很多函数吗:
@Actions( {
@Action(value = "/func1", results = {
@Result(name = "str1", type = "json")
})
})
public String func1(){
//instructions
return "str1";
}
@Actions( {
@Action(value = "/func2", results = {
@Result(name = "str2", type = "json")
})
})
public String func2(){
//instructions
return "str2";
}
还有许多 JSON 方法 getter,例如:
public String getJSON1()
{
func1();
}
public String getJSON2()
{
return func2();
}
在同一个动作类中?
非常感谢您。
【问题讨论】:
-
我不明白目标。 getJSONn 函数如何与操作方法相关联?
-
我认为他的意思是 get json 方法是动作。是的,您可以有多个返回 json 的操作方法。这往往会出现 FindEmployees、FindCustomers、FindSuppliers 的搜索参数相同的情况。然而,将导致多个动作的共性移动到它自己的带有字符串或更好的枚举的设置器中更有意义,然后你回到一个动作。
标签: jquery-plugins struts2 jsonplugin