实现CRUD的baseAction

package com.liuzm.mypss.web;

import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import com.opensymphony.xwork2.interceptor.annotations.InputConfig;

public abstract class CRUDAction<T> extends BaseAction implements
		ModelDriven<T>, Preparable {
	private static final long serialVersionUID = 1L;

	protected Long id;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public void prepare() throws Exception {

	}

	@Override
	@InputConfig(methodName = "execute")
	public String execute() throws Exception {
		list();
		return SUCCESS;
	}

	@Override
	public String input() {
		return INPUT;
	}

	protected abstract void list() throws Exception;

	protected abstract String save() throws Exception;

	protected abstract String delete() throws Exception;

	public void prepareInput() {
		beforeInput();
	}

	public void prepareSave() {
		beforeSave();
	}

	protected abstract void beforeInput();

	protected abstract void beforeSave();

}

 

你可能感兴趣的:(action)