IdEntity

package org.apache.struts2.showcase.model;

import java.io.Serializable;
IdEntity. Interface.

public interface IdEntity extends Serializable {

Serializable getId ();

void setId ( Serializable id );

}



public class Employee implements IdEntity {

private static final long serialVersionUID = -6226845151026823748L;

private Long empId; //textfield w/ conversion

public Employee() {
}

public Employee(Long empId) {
this.empId = empId;

}


public Long getEmpId() {
return empId;
}

public void setEmpId(Long empId) {
this.empId = empId;
}

public Serializable getId() {
return getEmpId();
}

public void setId(Serializable id) {
setEmpId((Long) id);
}
}




package org.apache.struts2.showcase.dao;

import java.io.Serializable;
import java.util.Collection;

import org.apache.struts2.showcase.exception.CreateException;
import org.apache.struts2.showcase.exception.StorageException;
import org.apache.struts2.showcase.exception.UpdateException;
import org.apache.struts2.showcase.model.IdEntity;

/**
* Dao. Interface.
*
*/

public interface Dao {

Class getFeaturedClass();


----->public Class getFeaturedClass() {
return Employee.class;
}

IdEntity get(Serializable id);

Serializable create(IdEntity object) throws CreateException;

IdEntity update(IdEntity object) throws UpdateException;

Serializable merge(IdEntity object) throws StorageException;

int delete(Serializable id) throws CreateException;

int delete(IdEntity object) throws CreateException;

Collection findAll();
}




package org.apache.struts2.showcase.filedownload;

import java.io.InputStream;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.Action;

/**
* Demonstrates file resource download.
* Set filePath to the local file resource to download,
* relative to the application root ("/images/struts.gif").
*
*/
public class FileDownloadAction implements Action {

private String inputPath;
public void setInputPath(String value) {
inputPath = value;
}

public InputStream getInputStream() throws Exception {
return ServletActionContext.getServletContext().getResourceAsStream(inputPath);
}

public String execute() throws Exception {
return SUCCESS;
}

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值