Bolg hasn't been here for a long time. If you have time, let's put a recently written webwork interceptor for your reference. If you have a bug or a better implementation method, please email me.
The following is the implementation code of interceptor:
1 package interceptor;
2
3 Import java. Io. ioexception;
4
5 import org. Apache. log4j. Logger;
6
7 Import com. Caucho. burlap. Io. burlapinput;
8 Import com. Caucho. burlap. Io. burlapoutput;
9 Import com. Caucho. burlap. server. burlapskeleton;
10 Import com. opensymphony. webwork. servletactioncontext;
11 import com. opensymphony. xwork. actioninvocation;
12 Import com. opensymphony. xwork. Interceptor. interceptor;
13
14 public class burlapinterceptor implements interceptor {
15 Private Static logger = logger. getlogger (burlapinterceptor. Class );
16 public void destroy (){
17 // todo auto-generated method stub
18
19}
20
21 public void Init (){
22 // todo auto-generated method stub
23
24}
25
26 Public String intercept (actioninvocation Invocation) throws exception {
27 burlapinput in = new burlapinput (servletactioncontext. getrequest ()
28. getinputstream ());
29
30 burlapoutput out = new burlapoutput (servletactioncontext. getresponse (). getoutputstream ()){
31 public void startreply () throws ioexception {
32 print ("<? XML version = \ "1.0 \" encoding = \ "UTF-8 \"?> <Burlap: reply xmlns: burlap = \ "http://www.buffalo.net/burlap/\"> ");
33}
34 };
35
36 burlapskeleton _ skeleton = new burlapskeleton (Invocation. getaction ());
37
38 try {
39 _ skeleton. Invoke (In, out );
40}
41 catch (throwable e ){
42 logger. Error ("cocould not invoke burlap", e );
43}
44 return NULL;
45}
46
47}
48
Then define in xwork. xml: 1 <interceptors>
2 <interceptor name = "burlap" class = "Interceptor. burlapinterceptor"/>
3 </interceptors>
4
It is best to use this Interceptor to define your own bean, for example: 1 <action name = "classtree" class = "classtreeaction" method = "getclasslist">
2 <Interceptor-ref name = "burlap"/>
3 </Action>
On the page, you can use the following JavaScript code to call this action:
VaR BFL = new Buffalo ("classtree. Page ");
BFL. remotecall ("getclasslist", [acadyear, semester], function (reply ){...});
If you don't know buffalo, you can go to his website to see: http://www.amowa.net/buffalo/