一、普通java类
package com.pb.web.action; /* * 创建普通的java类 */ public class HelloAction1 { public String execute(){ return "success"; } }
二、实现Action接口
package com.pb.web.action; import com.opensymphony.xwork2.Action; /* * 第二种实现Action接口 */ public class HelloAction2 implements Action { @Override public String execute() throws Exception { // TODO Auto-generated method stub return "success"; } }
三、继承ActionSupport
package com.pb.web.action; import com.opensymphony.xwork2.ActionSupport; /* * 第三种 继承 ActionSupport类它是Action的实现类 */ public class HelloAction3 extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; @Override public String execute() throws Exception { // TODO Auto-generated method stub return "success"; } }
时间: 2024-11-10 01:05:55