惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - 深夜

AMIS中的组件添加图标的一些注意点。 同一个浏览器多次请求竟然发现是串行执行的,见鬼了。 VSCode 运行go test显示打印日志 现在CSDN真的很讨厌,百度出来都是一堆CSDN的东西。 VScode中的golang代码规范太严格,怎么处理。 chromedp自动启动为headless模式 chromedp下载文件的方法,备忘一下。 vue项目里的日期格式化(摘录) 深入分析 Java 中的中文编码问题 高亮显示web页表格行 tomcat作为windows服务的参数配置,特别是PermSize的设置 webwork和spring多配置文件的方法 - 深夜 - 博客园 用C#实现BHO(Brower Helper Object) 用Sitemesh控制页面布局 关于WebWork2中的中文问题 tomcat中的几点配置说明 使用Filter实现静态HTML缓冲(一种折中方法) 关于DirectX中的DirectShow介绍 基于Delphi的VFW视频捕获程序的开发
webwork的interceptor来实现ajax功能(buffalo)
深夜 · 2005-10-21 · via 博客园 - 深夜

已经很久没有来bolg了,现在有空,就把最近写的一个webwork的拦截器放上来给大家参考,如果有bug或有更好的实现办法,可以email给我。

下面是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 = 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("Could not invoke burlap", e);
43         }
44         return null;
45     }
46 
47 }
48 

然后在xwork.xml中定义:

1         <interceptors>
2               <interceptor name="burlap" class="interceptor.BurlapInterceptor"/>        
3          </interceptors>
4 

最好就可以使用这个拦截器定义自己的bean了,例如:

1    <action name="classtree" class="classTreeAction" method="getClassList">
2        <interceptor-ref name="burlap" />
3    </action>

在页面上就可以用如下javascript代码去调用这个action:
   var bfl = new Buffalo("classtree.page");
   bfl.remoteCall("getClassList",[acadyear,semester],function(reply){...});

如果你不了解buffalo,可以去他的网站看看:http://www.amowa.net/buffalo/