package com.students.action;
import java.util.List;
import javax.annotation.Resource;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.validation.SkipValidation;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.ConversionErrorFieldValidator;
import com.opensymphony.xwork2.validator.annotations.IntRangeFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
import com.opensymphony.xwork2.validator.annotations.RequiredStringValidator;
import com.opensymphony.xwork2.validator.annotations.StringLengthFieldValidator;
import com.opensymphony.xwork2.validator.annotations.Validations;
import com.students.bean.ClassBean;
import com.students.bean.StuBean;
import com.students.service.ServiceInf;
//spring注解
@Controller("stuAction")
@Scope("request")
//struts2注解
@ParentPackage(value="struts2")
@Namespace(value="/manager")
@Results({
@Result(name="success", location="/index.jsp"),
@Result(name="addview", location="/addStu.jsp"),
@Result(name="modifyview", location="/modifyStu.jsp"),
@Result(name="error", location="/error.jsp")
})
//引用拦截器
@InterceptorRefs({
@InterceptorRef("defaultStack"),
@InterceptorRef("roles")
})
//注解验证
@Validations(requiredStrings={
@RequiredStringValidator(fieldName="bean.stuName",trim=true,key="validate.stuname"),
@RequiredStringValidator(fieldName="bean.sex",trim=true,key="validate.sex"),
@RequiredStringValidator(fieldName="bean.stuPasswd",trim=true,key="validate.stupassword"),
@RequiredStringValidator(fieldName="bean.stuPhone",trim=true,key="validate.phone"),
@RequiredStringValidator(fieldName="bean.stuAddress",trim=true,key="validate.address")
},requiredFields={
@RequiredFieldValidator(fieldName="bean.stuClass.id",key="validate.class"),
@RequiredFieldValidator(fieldName="bean.stuAge",key="validate.age")
},conversionErrorFields={
@ConversionErrorFieldValidator(fieldName="bean.stuAge",key="validate.checkage"),
@ConversionErrorFieldValidator(fieldName="bean.stuPhone",key="validate.errorphone")}
,stringLengthFields={
@StringLengthFieldValidator(fieldName="bean.stuPhone",minLength="11",maxLength="11",key="validate.checkphone")
},intRangeFields={
@IntRangeFieldValidator(fieldName="bean.stuAge",min="16",max="40",key="validate.agesize"),
})
public class StuAction extends ActionSupport{
private StuBean bean;
public StuBean getBean() {
return this.bean;
}
public void setBean(StuBean bean) {
this.bean = bean;
}
@Resource(name="service")
private ServiceInf service;
//配置文件在set方法中注入
public void setService(ServiceInf service) {
this.service = service;
}
//查询学员信息列表
@SkipValidation //表示此方法不验证
@Action(value="findStu")
public String find()throws Exception{
//ServiceInf service = BeanUtils.getContext().getBean("service", ServiceInf.class);
List<StuBean> list = service.findList();
ActionContext.getContext().put("list", list);
return SUCCESS;
}
//删除学员记录
@SkipValidation //表示此方法不验证
@Action(value="removeStu")
public String remove()throws Exception{
//ServiceInf service = BeanUtils.getContext().getBean("service", ServiceInf.class);
service.removeStu(bean.getSid());
return find();
}
@SkipValidation //表示此方法不验证
@Action(value="showAddStu")
public String showAdd()throws Exception{
//ServiceInf service = BeanUtils.getContext().getBean("service", ServiceInf.class);
List<ClassBean> list = service.findClass();
ActionContext.getContext().getSession().put("classlist", list);
return "addview";
}
//添加新学员
@Action(value="addStu",results={@Result(name="input",location="/addStu.jsp")})
public String add()throws Exception{
//ServiceInf service = BeanUtils.getContext().getBean("service", ServiceInf.class);
service.addStu(bean);
ActionContext.getContext().put("msg", getText("alert.add"));
return "addview";
}
@SkipValidation //表示此方法不验证
@Action(value="showModifyStu")
public String showModify()throws Exception{
//ServiceInf service = BeanUtils.getContext().getBean("service", ServiceInf.class);
this.bean = service.findStu(bean.getSid());
List<ClassBean> list = service.findClass();
ActionContext.getContext().getSession().put("classlist", list);
return "modifyview";
}
//修改学员信息
@Action(value="modifyStu",results={@Result(name="input",location="/modifyStu.jsp")})
public String modify()throws Exception{
//ServiceInf service = BeanUtils.getContext().getBean("service", ServiceInf.class);
this.bean = service.updateStu(bean);
ActionContext.getContext().put("msg",getText("alert.update"));
return "modifyview";
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SSH.zip_ssh
共213个文件
jar:69个
java:35个
class:35个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 182 浏览量
2022-09-21
17:10:43
上传
评论
收藏 26.78MB ZIP 举报
温馨提示
关于struts2、spring、hibernate框架整合案例,包括使用配置文件和注解两个项目。
资源推荐
资源详情
资源评论
收起资源包目录
SSH.zip_ssh (213个子文件)
StuAction.class 5KB
DaoImpl.class 3KB
StuBean.class 3KB
DaoImpl.class 3KB
StuAction.class 3KB
ServiceImpl.class 3KB
LoginAction.class 2KB
ServiceImpl.class 2KB
DBConnection.class 2KB
UpdateAspect.class 2KB
AddAspect.class 2KB
StuBean.class 2KB
UpdateAspect.class 2KB
AddAspect.class 2KB
DBConnection.class 2KB
ClassBean.class 2KB
LangAction.class 2KB
LoginAction.class 2KB
MyInterceptor.class 1KB
UserBean.class 1KB
ClassBean.class 1KB
LangAction.class 1KB
MyInterceptor.class 1KB
SessionUtil.class 1KB
SessionUtil.class 1KB
UserBean.class 988B
JndiUtil.class 895B
JndiUtil.class 895B
PointCut.class 658B
BeanUtils.class 637B
BeanUtils.class 637B
ServiceInf.class 604B
ServiceInf.class 604B
DaoInf.class 531B
DaoInf.class 531B
.classpath 727B
.classpath 548B
org.eclipse.wst.common.component 457B
org.eclipse.wst.common.component 454B
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.jsdt.ui.superType.container 49B
hibernate3.jar 3.9MB
hibernate3.jar 3.9MB
aspectjweaver.jar 1.47MB
aspectjweaver.jar 1.47MB
xwork-core-2.2.1.1.jar 997KB
xwork-core-2.2.1.1.jar 997KB
freemarker-2.3.16.jar 860KB
freemarker-2.3.16.jar 860KB
struts2-core-2.2.1.1.jar 755KB
struts2-core-2.2.1.1.jar 755KB
org.springframework.context-3.0.5.RELEASE.jar 653KB
org.springframework.context-3.0.5.RELEASE.jar 653KB
commons-collections-3.1.jar 546KB
commons-collections-3.1.jar 546KB
org.springframework.beans-3.0.5.RELEASE.jar 542KB
org.springframework.beans-3.0.5.RELEASE.jar 542KB
javassist-3.7.ga.jar 531KB
javassist-3.7.ga.jar 531KB
sqljdbc4.jar 455KB
sqljdbc4.jar 455KB
antlr-2.7.6.jar 433KB
antlr-2.7.6.jar 433KB
org.springframework.web-3.0.5.RELEASE.jar 386KB
org.springframework.web-3.0.5.RELEASE.jar 386KB
org.springframework.jdbc-3.0.5.RELEASE.jar 377KB
org.springframework.jdbc-3.0.5.RELEASE.jar 377KB
org.springframework.core-3.0.5.RELEASE.jar 373KB
org.springframework.core-3.0.5.RELEASE.jar 373KB
org.springframework.orm-3.0.5.RELEASE.jar 326KB
org.springframework.orm-3.0.5.RELEASE.jar 326KB
backport-util-concurrent.jar 320KB
backport-util-concurrent.jar 320KB
org.springframework.aop-3.0.5.RELEASE.jar 314KB
org.springframework.aop-3.0.5.RELEASE.jar 314KB
dom4j-1.6.1.jar 307KB
dom4j-1.6.1.jar 307KB
ehcache-1.5.0.jar 258KB
ehcache-1.5.0.jar 258KB
org.springframework.transaction-3.0.5.RELEASE.jar 226KB
org.springframework.transaction-3.0.5.RELEASE.jar 226KB
ognl-3.0.jar 224KB
ognl-3.0.jar 224KB
org.springframework.expression-3.0.5.RELEASE.jar 166KB
org.springframework.expression-3.0.5.RELEASE.jar 166KB
aspectjrt.jar 112KB
aspectjrt.jar 112KB
hibernate-jpa-2.0-api-1.0.0.Final.jar 99KB
hibernate-jpa-2.0-api-1.0.0.Final.jar 99KB
commons-io-1.3.2.jar 86KB
commons-io-1.3.2.jar 86KB
struts2-convention-plugin-2.2.1.1.jar 64KB
commons-fileupload-1.2.1.jar 56KB
commons-fileupload-1.2.1.jar 56KB
org.springframework.asm-3.0.5.RELEASE.jar 52KB
org.springframework.asm-3.0.5.RELEASE.jar 52KB
commons-logging-1.0.4.jar 37KB
commons-logging-1.0.4.jar 37KB
org.springframework.aspects-3.0.5.RELEASE.jar 35KB
org.springframework.aspects-3.0.5.RELEASE.jar 35KB
共 213 条
- 1
- 2
- 3
资源评论
局外狗
- 粉丝: 69
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功