/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package web.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.actions.DispatchAction;
import web.form.PetForm;
import biz.PetDiaryBiz;
import biz.PetInfoBiz;
import biz.impl.PetInfoBizImpl;
import entity.PageResult;
import entity.PetDiary;
import entity.PetInfo;
import ajax.PetManager;
/**
* MyEclipse Struts Creation date: 08-11-2009
*
* XDoclet definition:
*
* @struts.action path="/doLogin" name="loginDynaForm"
* input="/form/loginDyna.jsp" scope="request" validate="true"
* @struts.action-forward name="showBaby" path="/WEB-INF/jsp/pet/showBaby.jsp"
* @struts.action-forward name="error" path="/WEB-INF/jsp/error.jsp"
*/
public class PetAction extends DispatchAction {
/*
* Generated Methods
*/
// 全局变量 方便调用
// private PetInfoBiz biz = new PetInfoBizImpl();
// private PetDiaryBiz petDiaryBiz = new PetDiaryBizImpl();
// 得到BIZ实例
// private PetDiaryBiz petDiaryBiz = (PetDiaryBiz)
// SpringUtil.getBean("petDiaryBiz");
// private PetInfoBiz biz = (PetInfoBiz) SpringUtil.getBean("petInfoBiz");
private PetDiaryBiz petDiaryBiz = null;
private PetInfoBiz biz = null;
// 增加set方法 为注入做准备
public void setPetDiaryBiz(PetDiaryBiz petDiaryBiz) {
this.petDiaryBiz = petDiaryBiz;
}
// 增加set方法 为注入做准备
public void setBiz(PetInfoBiz biz) {
this.biz = biz;
}
/**
* 登陆
*/
public ActionForward doLogin(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward af = null;
// 获取表单参数
PetForm loginDynaForm = (PetForm) form;// TODO
// Auto-generated
// method stub
PetInfo condition = loginDynaForm.getItem();
String checkedNum = loginDynaForm.getChecked();
// 获取验证码中的随即数字
String num = (String) request.getSession().getAttribute("vcode");
if (null != num) {
if (num.equals(checkedNum)) {
// 调用业务逻辑方法
PetInfo petInfo = new PetInfo();
System.out.println("输出接收值1:" + condition);
petInfo = biz.login(condition);
if (null != petInfo) {
int strength = petInfo.getPetStrength();// 获得宠物力量值
int cute = petInfo.getPetCute();// 获得宠物能力值
int love = petInfo.getPetLove();// 获得宠物爱心
// 获得宠物状态
this.doSeeion(strength, cute, love, request);
// 将宠物数据保存到session中
request.getSession(true).setAttribute("current_pet",
petInfo);
// 调用业务逻辑方法
System.out.println("登陆宠物ID:\n" + petInfo.getPetId() + "\n");
List<PetDiary> diaryList = petDiaryBiz
.getLitByPetID(petInfo.getPetId());
if (null != diaryList) {
// 将宠物数据保存到session中
request.getSession().setAttribute("diaryList",
diaryList);
System.out.println("登陆时加载日记:\n" + diaryList + "\n数量:"
+ diaryList.size());
af = mapping.findForward("showBaby");
} else {
request.setAttribute("error", "查询日记出错!");
af = mapping.findForward("error");
}
} else {
// 输入合法性验证
// errors用于保存出错信息
ActionMessages errors = new ActionMessages();
// 根据业务逻辑进行判断,对出错的情况添加错误信息到errors中
errors.add("login", new ActionMessage(
"error.validate.number"));
/**
* error.validate.number对应到资源文件中的属性名称 login 是出错信息名
* 在页面显示错误时可根据名称来引用出错信息 对同一个名称,可添加多个出错信息
* errors.add("login",new
* ActionMessage("error.validate.number"));里面参数写的是配置文件中定义的信息名
* 而不能直接指定错误信息 如以下便是错误的new ActionMessage("宠物ID或密码错误,请重试!")
* 如果不是需要单独指定错误信息,在页面里统一显示错误信息即可,
* 则可以将错误信息添加到GLOBAL_MESSAGE名下
* errors.add(ActionMessages.GLOBAL_MESSAGE,new
* ActionMessage("宠物ID或密码错误,请重试!"));
* 可用cmd修改指定error.validate.number中的信息
* 如首先寻找到jdk中的配置文件native2ascii.exe 把它拖到cmd控制台中 或可直接在配置文件修改
* 是一个专门的组件 适用于处理中文 错误信息显示也可用JavaScript显示 如:errors.header =
* <script alert("> errors.footer = ");</script>
*/
// 判断errors中是否有错误信息
if (!errors.isEmpty()) {
super.saveErrors(request, errors);
af = mapping.findForward("index");
}
}
} else {
// 输入合法性验证
// errors用于保存出错信息
ActionMessages errors = new ActionMessages();
// 根据业务逻辑进行判断,对出错的情况添加错误信息到errors中
errors.add("login", new ActionMessage("validate.number"));
// 判断errors中是否有错误信息
if (!errors.isEmpty()) {
super.saveErrors(request, errors);
af = mapping.findForward("index");
}
}
}
return af;
}
/**
* 宠物喂食
* @throws IOException
*/
public ActionForward doFeed(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
ActionForward af = null;
// 获取表单参数
PetForm comnForm = (PetForm) form;
PetInfo petInfo = (PetInfo) request.getSession().getAttribute(
"current_pet");
if (null != petInfo) {
int petId = petInfo.getPetId();
// 调用业务逻辑方法
int result = biz.doFeed(petId);
petInfo = biz.load(petId);
int strength = petInfo.getPetStrength();// 获得宠物力量值
int cute = petInfo.getPetCute();// 获得宠物能力值
int love = petInfo.getPetLove();// 获得宠物爱心
// 获得宠物状态
this.doSeeion(strength, cute, love, request);
request.getSession(true).setAttribute("current_pet", petInfo);
//设置输出编码方式
response.setCharacterEncoding("GBK");
//打印输出结果
response.getWriter().print(this.getScoreString(petId));
if (result > 0) {
if ("show".equals(comnForm.getParam())) {
af = mapping.findForward("showBaby");
} else {
af = mapping.findForward("write");
}
} else {
// 将错误数据存储到request中
request.setAttribute("error", "玩游戏出错了!");
// 将请求转发逻辑名为"error"的页面
af = mapping.findForward("error");
}
}
return null;
}
/**
* 讲故事
* @throws IOException
*/
public ActionForward doStory(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws IOException {
ActionForward af = null;
// 获取表单参数
PetForm comnForm = (PetForm) form;// TODO
PetInfo petInfo = (PetInfo) request.getSession().getAttribute(
"current_pet");
if (null != petInfo) {
int petId = petInfo.getPetId();
// 调用业务逻辑方法
int result = biz.doStory(petId);
petInfo = biz.load(petId);
int strength = petInfo.getPetStrength();// 获得宠物力量值
int cute = petInfo.getPetCute();// 获得宠物能力值
int love = petInfo.getPetLove();// 获得宠物爱心
// 获得宠物状态
this.doSeeion(strength, cute, love, request);
request.getSession(true).setAttribute("current_pet", petInfo);
//设置输出编码方式
response.setCharacterEncoding("GBK");
//打印输出结果
response.getWriter().print(this.getScoreString(petId));
if (result > 0) {
if ("show".equals(comnForm.getParam())) {
af = mapping.findForward("showBaby");
} else {
af = mapping.findForward("write");
}
} else {
// 将错误数据存储到request中
request.setAttribute("error", "玩游戏出错了!");
//
没有合适的资源?快使用搜索试试~ 我知道了~
JAVA宠物网站--epet(struts+Hibernate+Spring+Ajax版)
共236个文件
jar:45个
class:39个
jpg:39个
5星 · 超过95%的资源 需积分: 9 61 下载量 54 浏览量
2009-09-21
09:08:23
上传
评论 7
收藏 12.6MB RAR 举报
温馨提示
该资源采用JAVA技术开发 其中包含网站 等等源代码 其中最主要的技术为 使用struts技术、Hibernate、 Hibernate标签、国际化技术、Spring、Ajax技术等等 且此网站开发为宠物网站 包含领养宠物 登陆 显示宠物列表 写宠物日记 查询宠物 分页 喂养宠物 与宠物游戏、讲故事 显示宠物详情等等内容 一看便知(由于上传权限有限 数据库为额为上传的 若需要 可再去下载 资源名称为:epet 与epai数据库)
资源推荐
资源详情
资源评论
收起资源包目录
JAVA宠物网站--epet(struts+Hibernate+Spring+Ajax版) (236个子文件)
PetAction.class 12KB
PetInfoDAOJdbcImpl.class 7KB
PetInfoDAOHibImpl.class 6KB
PetInfoDAOHibImpl2.class 6KB
PetDiaryDAOJdbcImpl.class 6KB
DiaryAction.class 6KB
PetDiaryDAOHibImpl.class 6KB
PetInfo.class 6KB
PetDiaryDAOHibImpl2.class 5KB
PetDiary.class 5KB
BaseHibernateDAO_ch7.class 4KB
Controller.class 4KB
PetInfoBizImpl.class 3KB
BaseJdbcDAO.class 3KB
BaseHibernateDAO.class 3KB
PetForm.class 3KB
DiaryAdvice2.class 3KB
ShowBabyServlet.class 3KB
PetInfoDAOHibImpl$1.class 3KB
PetManager.class 3KB
PetDiaryBizImpl.class 3KB
LotteryAdvice2.class 2KB
HibernateSessionFactory.class 2KB
LotteryAdvice.class 2KB
DiaryAdvice.class 2KB
ShowBabyAction.class 2KB
PageResult.class 2KB
GBKFilter.class 1KB
DiaryForm.class 1KB
ProReader.class 1KB
SpringUtil.class 969B
Test.class 901B
PetInfoBiz.class 736B
PetDiaryBiz.class 732B
PetInfoDAO.class 677B
Test.class 666B
Tool.class 641B
PetDiaryDAO.class 618B
Action.class 217B
.classpath 4KB
calendar-system.css 4KB
calendar-system.css 4KB
styles.css 629B
styles.css 629B
date_popup.gif 135B
date_popup.gif 135B
index.htm 13KB
pet_list.htm 12KB
diary_list.htm 12KB
adopt.htm 5KB
pet.htm 5KB
diary.htm 2KB
write_diary.html 5KB
pet.html 5KB
diary.html 2KB
hibernate3.jar 2.15MB
aspectjweaver.jar 1.82MB
xerces-2.6.2.jar 987KB
dwr.jar 494KB
spring-beans.jar 473KB
javassist.jar 460KB
spring-context.jar 458KB
antlr-2.7.6.jar 433KB
log4j-1.2.15.jar 383KB
log4j-1.2.15.jar 383KB
log4j-1.2.15.jar 383KB
spring-orm.jar 364KB
log4j-1.2.11.jar 342KB
spring-aop.jar 318KB
cglib-nodep-2.1_3.jar 317KB
spring-jdbc.jar 310KB
dom4j-1.6.1.jar 307KB
spring-core.jar 279KB
cglib-2.1.3.jar 276KB
sqljdbc.jar 227KB
spring-tx.jar 222KB
jaxen-1.1-beta-7.jar 222KB
ehcache-1.2.3.jar 203KB
commons-collections-2.1.1.jar 171KB
jaxen-core.jar 157KB
jdom.jar 150KB
xml-apis.jar 121KB
aspectjrt.jar 112KB
jaas.jar 102KB
persistence.jar 69KB
commons-logging.jar 59KB
commons-logging-1.0.4.jar 37KB
commons-attributes-api.jar 35KB
commons-attributes-compiler.jar 29KB
asm.jar 26KB
saxpath.jar 23KB
spring-aspects.jar 20KB
asm-attrs.jar 16KB
jta.jar 9KB
spring-tomcat-weaver.jar 8KB
aspectjlib.jar 8KB
jdbc2_0-stdext.jar 7KB
jaxen-jdom.jar 6KB
spring-agent.jar 5KB
aopalliance.jar 4KB
共 236 条
- 1
- 2
- 3
资源评论
- miyaliunian2014-05-28东西整体不错。。。可以用来学习
- skywxy1232012-07-16东西整体不错。。。可以用来学习。。。包含了Ajax技术。。加SHH框架
- Rightmexxx2014-05-17是电子宠物网站,还不错
- lm07132014-02-25比较齐全。整体不错
- @永不凋零2019-05-01不错的资源
xuanying2005
- 粉丝: 9
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功