注解:struts2-convention-plugin-2.2.3.1.jar的annotation包下的注解类
1、注解Action
@Namespace("/collectionbook")
public class CollectionBookAction extends BaseAction
{
}
2、注解方法
1.跳转到视图
@Action(value="initCollectionBook",
results = { @Result(name = "success", location= "xxx.jsp"),
@Result(name = "error", location = "xxx.error.jsp")
}
)
public String initCollectionBook()
{ return "success";}
2.跳转到同一action的另一个method
@Action(value="initCollectionBook",
results = { @Result(name = "success", location= "selectCollectionBook")},
type="chain"
)
public String initCollectionBook()
{ return "success";}
3.返回json
@Namespace("/collectionbook")
public class CollectionBookAction extends BaseAction
{
private List<StudentHistoryAnswer> stuHisAnswers;
//getter/setter方法
@Action(value = "selectStuHisAnwsers",
results = { @Result( name = "json", type = "json",
params = {"root", "stuHisAnswers" }
)
}
)
public String selectStuHisAnwsers()
{
List<StudentHistoryAnswer> stuHisAnswers=xxx;
return "json";
}
}