JAVA三级机试综合体要点.docx
- 文档编号:23259004
- 上传时间:2023-05-15
- 格式:DOCX
- 页数:23
- 大小:817.74KB
JAVA三级机试综合体要点.docx
《JAVA三级机试综合体要点.docx》由会员分享,可在线阅读,更多相关《JAVA三级机试综合体要点.docx(23页珍藏版)》请在冰豆网上搜索。
JAVA三级机试综合体要点
JAVA三级机试综合题
1.建数据库和表
要点:
素材,ID自增,ER图
综合能力的数据库新建表共8个字段,7个目标字段和1个主键
idint(10)
fistnamevarchar(20)
lastnamevarchar(30)
jobtitlevarchar(30)
departmentvarchar(40)
phonevarchar(20)
mobilevarchar(20)
emailvarchar(50)
PRIMARYKEY(`id`)
2.新建WebProject
要点:
ProjectName要符合命名规范,选JavaEE5.0
3.构筑Struts框架
要点:
选Struts1.3,PackageName改为com.struts
4.配置Hibernate
4.1.数据池
要点:
依赖素材db文件夹下的”连接字符串.txt”
4.2.构筑Hibernate框架
要点:
JavaPackage:
New-->com.dao,JAVA5.0
4.3.建立addresstable表和Hibernate框架的映射
要点:
选工程,三个勾,identity
4.4.拷贝素材
把pages文件夹下的images文件夹和style文件夹复制到工程中的WebRoot文件夹下
5.程序框架
5.1.建包com.web
5.2.建类3个
5.2.1.ContactForm类
packagecom.web;
importorg.apache.struts.action.ActionForm;
publicclassContactFormextendsActionForm{
privateStringfirstName;
privateStringlastName;
privateStringjobTitle;
privateStringdepartment;
privateStringphone;
privateStringmobile;
privateStringemail;
publicStringgetFirstName(){
returnfirstName;
}
publicvoidsetFirstName(StringfirstName){
this.firstName=firstName;
}
publicStringgetLastName(){
returnlastName;
}
publicvoidsetLastName(StringlastName){
this.lastName=lastName;
}
publicStringgetJobTitle(){
returnjobTitle;
}
publicvoidsetJobTitle(StringjobTitle){
this.jobTitle=jobTitle;
}
publicStringgetDepartment(){
returndepartment;
}
publicvoidsetDepartment(Stringdepartment){
this.department=department;
}
publicStringgetPhone(){
returnphone;
}
publicvoidsetPhone(Stringphone){
this.phone=phone;
}
publicStringgetMobile(){
returnmobile;
}
publicvoidsetMobile(Stringmobile){
this.mobile=mobile;
}
publicStringgetEmail(){
returnemail;
}
publicvoidsetEmail(Stringemail){
this.email=email;
}
}
5.2.2.AddContactAction类
packagecom.web;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importorg.apache.struts.action.Action;
importorg.apache.struts.action.ActionForm;
importorg.apache.struts.action.ActionForward;
importorg.apache.struts.action.ActionMapping;
importcom.dao.Addresstable0;
importcom.dao.Addresstable0DAO;
publicclassAddContactActionextendsAction{
@Override
publicActionForwardexecute(ActionMappingmapping,ActionFormform,
HttpServletRequestrequest,HttpServletResponseresponse)
throwsException{
//callbusinessclass
ContactFormcontactForm=(ContactForm)form;
Addresstable0addresstable=newAddresstable0(
contactForm.getFirstName()
contactForm.getLastName()
contactForm.getJobTitle()
contactForm.getDepartment()
contactForm.getPhone()
contactForm.getMobile()
contactForm.getEmail());
Addresstable0DAOadao=newAddresstable0DAO();
adao.save(addresstable);
returnmapping.findForward("success");
}
}
5.2.3.ListContactAction类
packagecom.web;
importjava.util.List;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importorg.apache.struts.action.Action;
importorg.apache.struts.action.ActionForm;
importorg.apache.struts.action.ActionForward;
importorg.apache.struts.action.ActionMapping;
importcom.dao.Addresstable0DAO;
publicclassListContactActionextendsAction{
@Override
publicActionForwardexecute(ActionMappingmapping,ActionFormform,
HttpServletRequestrequest,HttpServletResponseresponse)
throwsException{
//TODOAuto-generatedmethodstub
Addresstable0DAOadao=newAddresstable0DAO();
Listlist=adao.findAll();
request.getSession().setAttribute("list",list);
returnmapping.findForward("success");
}
}
5.3.建jsp
5.3.1.addContact.jsp
<%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%>
MARGINHEIGHT=0> cellspacing="0"> onsubmit="returnvalidateTitle()"> ADDNEWCONTACTDETAILS
FIRSTNAME:
LASTNAME:
JOBTITLE:
DEPARTMENT:
PHONE:
MOBILE:
E-MAIL:
2010XXXInformationTechnologyCo.,Ltd版权所有