使用继承的Struts2 Convention插件结果 [英] Struts2 Convention Plugin Results Using Inheritance
本文介绍了使用继承的Struts2 Convention插件结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法让struts2约定插件使用来自超类的结果?
Is there a way to make the struts2 convention plugin use results from a super class?
我正在尝试创建一般CRUD,并使用一般结果子类中没有实现。这可能吗?
I'm trying to create a general CRUD, and use general results if there is no implementation in the child class. Is this possible?
推荐答案
是的,你可以。
例如:
一般CRUD
@Results({
@Result(name = "input", location = "input.jsp"),
@Result(location = "input.jsp")
})
public abstract class CrudActionSupport extends ActionSupport {
@Action("update/{entityId}") // wildcard mapping
public String actionUpdate() {
return SUCCESS;
}
}
操作
public class PersonAction extends CrudActionSupport {
}
的注释CrudActionSupport 将始终有效,除非它在子类中被覆盖。
The annotation at CrudActionSupport will always in effect, except it is overridden in subclass.
例如
@Results({
@Result(name = "input", location = "person.jsp"),
@Result(location = "person.jsp")
})
public class PersonAction extends CrudActionSupport {
@Override
public String actionUpdate() {
return SUCCESS;
}
// or
/*
@Action("update/{id}")
@Override
public String actionUpdate() {
return SUCCESS;
}
*/
}
这篇关于使用继承的Struts2 Convention插件结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文