how to populate drop down with prepare interface
i saw a link struts2 drop down but i am unable to understand how to use prepare interceptor. how will request be forwarded to jsp and view method will be called
can anyone give me a example?
public class YourAction extends ActionSupport {
public String prepare(){
// populate your开发者_C百科 drop down object
}
public String view(){
// forward to your jsp
return SUCCESS;
}
}
Interceptors are invoked before and/or after the execution of action depending on the interceptor type.In your case the prepare interceptor is used. To understand the workflow of the interceptors in general take a look here
Regarding the prepare interceptors you should read this article before using it.
Try to use method name prepareView()
instead of prepare()
.
As, prepare()
will be called before any method in this class and prepareView()
will be called only before view()
.
精彩评论