这是翻译的turbine的一篇文档,howto系列的action event,第一次翻译,比较短的一篇,如果有不大通顺的地方,情告诉我,原文地址http: //jakarta.apache.org/turbine/turbine-2.3/howto/action-event-howto.html
action events
turbine 有一个非常好的功能来帮助开发人员处理web耶面的提交数据.为了理解这一功能,你需要知道turbine是如何处理一次提交的.
事实上,当在一个uri中只要发现有action这个变量出现,在执行所有screen类之前会执行一个程序,我们来看下面这个例子(来自velocitysite的howto示例):
对于url"http: //www.server.com/servlet/turbine/template/adduser/action/newuser",turbine 会首先执行一个名叫"newuse"的action类,在这种情况下,所有继承actionevent而不是action的类都可以象如下的代码一样方便的处理:
public class newuser extends velocityaction
{
public void doadd (rundata data, context context) throws exception
{
// put code here to add the user to the system
context.put ("username", username );
data.setmessage("user added!");
}
public void doperform(rundata data, context context) throws exception
{
data.setmessage("button not found!");
}
}
<input type="submit" name="eventsubmit_doadd" value="add user">
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器