日期:2014-05-16  浏览次数:20578 次

eweb demo war包+源码+db脚本 下载 (1.8.x-SNAPSHOT)
看来,年内发布一个完整的新版本比较难了.

实在是要忙公司的项目.

eweb框架虽然也在持续开发中,
不过因为新版本的文档资料还没有重新编写,
所以只能先放出一个正在开发中的演示,虽然是演示,
不过该版本已经比较稳定了.

这次放出的压缩包解开之后有三个东西:

源代码:eweb4j-petstore-sources.jar

war部署包:eweb4j-petstore.war

数据库脚本(mysql):petstore_db.sql

如果需要其他数据库,自己写一个吧,才两个表,一个外键关系而已.

放一张截图吧:



各位请放心下载哇.

上几句代码吧:
package com.cfuture08.eweb4j.demo.petstore.pet.web;

import java.util.Arrays;


import com.cfuture08.eweb4j.demo.petstore.AbstractAction;
import com.cfuture08.eweb4j.demo.petstore.pet.Pet;
import com.cfuture08.eweb4j.demo.petstore.pet.PetException;
import com.cfuture08.eweb4j.mvc.annotation.POST;
import com.cfuture08.eweb4j.mvc.annotation.Path;

/**
 * 添加宠物信息控制器
 * 
 * @author weiwei
 * 
 */

public class AddPetInfoAction extends AbstractAction {

	/**
	 * 接收页面表单数据,提供验证规则
	 */
	private Pet pet = null;

	/**
	 * 处理HTTP请求 POST http://{host}:{port}/eweb/pets/
	 * 
	 * @return
	 */
	@Path("pets/")
	@POST
	public String doPost() {
		request.setAttribute("types", Arrays.asList("猫", "狗", "猪"));
		try {
			petService.create(pet);
		} catch (PetException e) {
			request.setAttribute("error", e.getMessage());
			return "../error.jsp";
		}

		return "redirect:list";
	}

	public Pet getPet() {
		return pet;
	}

	public void setPet(Pet pet) {
		this.pet = pet;
	}

}


package com.cfuture08.eweb4j.demo.petstore;

import javax.servlet.http.HttpServletRequest;


import com.cfuture08.eweb4j.demo.petstore.master.MasterService;
import com.cfuture08.eweb4j.demo.petstore.pet.PetService;
import com.cfuture08.eweb4j.ioc.annotation.Ioc;

/**
 * 宠物信息抽象控制器
 * 
 * @author weiwei
 * 
 */

public abstract class AbstractAction {

	/**
	 * 通过IOC容器注入
	 */
	@Ioc("petService")
	protected PetService petService;

	/**
	 * 通过IOC容器注入
	 */
	@Ioc("masterService")
	protected MasterService masterService;

	/**
	 * 声明且提供setter方法,框架就能自动注入
	 */
	protected HttpServletRequest request;

	public PetService getPetService() {
		return petService;
	}

	public void setPetService(PetService petService) {
		this.petService = petService;
	}

	public MasterService getMasterService() {
		return masterService;
	}

	public void setMasterService(MasterService masterService) {
		this.masterService = masterService;
	}

	public HttpServletRequest getRequest() {
		return request;
	}

	public void setRequest(HttpServletRequest request) {
		this.request = request;
	}

}



package com.cfuture08.eweb4j.demo.petstore.pet;

import java.util.List;

import com.cfuture08.eweb4j.orm.dao.DAO;
import com.cfuture08.eweb4j.orm.dao.DAOException;
import com.cfuture08.eweb4j.orm.dao.cascade.CascadeDAO;
import com.cfuture08.eweb4j.orm.dao.delete.DeleteDAO;
import com.cfuture08.eweb4j.orm.dao.factory.DAOFactory;
import com.cfuture08.eweb4j.orm.dao.insert.InsertDAO;
import com.cfuture08.eweb4j.orm.dao.select.DivPageDAO;
import com.cfuture08.eweb4j.orm.dao.select.SelectDAO;
import com.cfuture08.eweb4j.orm.dao.update.UpdateDAO;

/**
 * 宠物信息服务接口实现类
 * 
 * @author weiwei
 * 
 */
public class PetServiceImpl implements PetService {
	private DivPageDAO divPageDAO;
	private CascadeDAO cascadeDAO;
	private SelectDAO selectDAO;
	private InsertDAO insterDAO;
	private UpdateDAO updateDAO;
	private DeleteDAO deleteDAO;

	// 这是一个用来拼凑sql语句的接口,
	// 是在ORM映射之下的.并不是直接拼凑原生SQL
	private DAO dao;

	public PetServiceImpl() {
		this.divPageDAO = DAOFactory.getDivPageDAO();
		this.cascadeDAO = DAOFactory.getCascadeDAO();
		this.selectDAO = DAOFactory.getSelectDAO();
		this.insterDAO = DAOFactory.getInsertDAO();
		this.updateDAO = DAOFactory.getUpdateDAO();
		this.deleteDAO = DAOFactory.getDeleteDAO();
		this.dao = DAOFactory.getDAO(Pet.cl