关键词不能为空

当前您在: 主页 > 英语 >

SSI框架的一个简单小项目

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2021-02-24 15:47
tags:

-

2021年2月24日发(作者:oaa)


SSI(Struts2+Spring+Ibatis)


的简单小项目



1




新建


web


项目



2




加入


jar











< br>





< /p>





< p>








、< /p>





3




写实体


bean



package



import izable;


import



public class Student extends Page {


private int id


private String username;


private String password;


private String phone;


private String email;


private String address


private Page page;


public void setPage(Page page) {



= page;


}


public int getId() {



return id;


}


public void setId(int id) {



= id;


}


public String getUsername() {



return username;


}


public void setUsername(String username) {



me = username;


}


public String getPassword() {



return password;


}


public void setPassword(String password) {



rd = password;


}


public String getPhone() {



return phone;


}


public void setPhone(String phone) {



= phone;


}


public String getEmail() {



return email;


}


public void setEmail(String email) {



= email;


}


public String getAddress() {



return address;


}


public void setAddress(String address) {



s = address;


}



}



package



import izable;



public class Users implements Serializable {


private String username ;


private String password


public String getUsername() {



return username;


}


public void setUsername(String username) {



me = username;


}


public String getPassword() {



return password;


}


public void setPassword(String password) {



rd = password;


}



}





package



import izable;


import



public class Page{










private int pagesize;//


单页记录











private int currentpage = 1;//


当前页面











private int countdate;//


总记录数











private int lastPage;//


上一页











private int nextPage;//


下一页











private int countPage;










public int getCurrentpage()











{


















return currentpage;










}










public void setCurrentpage(int currentpage)











{



































if(currentpage>getCountpage())


















{


























tpage = getCountpage();


















}else {


























if(currentpage < 1)


























{


































tpage = 1;


























}


























else


























{


































tpage = currentpage;


























}


















}










}










public int getPagesize() {


















return pagesize;










}










public void setPagesize(int pagesize) {


















ze = pagesize;










}










public int getCountdate()











{


















return countdate;










}










public void setCountdate(int countdate)











{


















ate = countdate;










}










//


由记录数设定有关的页面数。











public int getCountpage()











{


















int i = ate / ze;


















if((ate % ze)!=0)


















{


























i+=1;


















}


















return i;










}










public int getLastPage()










{


















return rentpage()-1;










}










public int getNextPage()










{


























return rentpage()+1;










}










//



ibatis


用数据











public int getCurrent()











{


















return (tpage-1)*pagesize;










}










public int getNext() {


















return tpage*pagesize;










}










public int getCountPage() {


















return countPage;










}










public void setCountPage(int countPage) {


















age = countPage;










}










public void setLastPage(int lastPage) {


















ge = lastPage;










}










public void setNextPage(int nextPage) {


















ge = nextPage;










}



}


4



< /p>


编写


dao


及其实现类

< br>



package


import


import t;



public interface StudentDao {



public boolean saveStu(Student student);



public boolean delStu(int id);



public boolean updateStu(Student student);



public List queryAll();



public Student queryById(int id);



public List dimStu(Student student);



public int getCountSize(Object obj);



}





package



import eption;


import



import tedList;


import Client;


import tDao;


import t;



public class StudentDaoImpl implements StudentDao {




private SqlMapClient sqlMapClient;





public void setSqlMapClient(SqlMapClient sqlMapClient) {




Client = sqlMapClient;



}





public boolean delStu(int id) {




try {





int i = (





if(i>0){






return true;





}else{






return false;





}




} catch (SQLException e) {





tackTrace();





return false;




}



}




public List queryAll() {




List list = null;










Student st = new Student();




try {





list = orList(




} catch (SQLException e) {





// TODO Auto-generated catch block





tackTrace();




}




return list;



}




public Student queryById(int id) {




Student student = null;




try {





student = (Student) orObject(




} catch (SQLException e) {





tackTrace();




}




return student;



}




public boolean saveStu(Student student) {




boolean b;




try {





(





b = true;




} catch (SQLException e) {





tackTrace();





b = false;




}




return b



}




public boolean updateStu(Student student) {




boolean b




try {





(





b = true;




} catch (Exception e) {





b = false;




}




return b;



}




public List dimStu(Student student) {




List list = null;




try {





list = orList(




} catch (SQLException e) {





tackTrace();




}




return list;



}




public int getCountSize(Object obj) {




int i = 0




try {





i = (Integer)orObject(




} catch (SQLException e) {





// TODO Auto- generated catch block





tackTrace();




}




return i



}



}



package



import ;



public interface UserDao {



public boolean isLogin(Users user);


}



package



import eption;


import



import Client;


import o;


import



public class UserDaoImpl implements UserDao {




private SqlMapClient sqlMapClient;





public void setSqlMapClient(SqlMapClient sqlMapClient) {




Client = sqlMapClient;



}




public boolean isLogin(Users user) {




try {





List list = orList(






if(()>0)












{



















return true;












}




} catch (SQLException e) {





tackTrace();




}




return false;



}



}


5




编写服务层及其实现




package t. servcie;


import


import t;



public interface StudentDao {



public boolean saveStu(Student student);



public boolean delStu(int id);



public boolean updateStu(Student student);



public List queryAll();



public Student queryById(int id);



public List dimStu(Student student);



public int getCountSize(Object obj);



}




package



import ;



import tDao;


import t;


import tService;



public class StudentServiceImpl implements StudentService {



private StudentDao sdao;



public void setSdao(StudentDao sdao) {



= sdao;


}



public boolean delStu(int id) {



boolean b = (id);



if(b){




return true;



}else{




return false;



}


}



public List queryAll() {



List list = ll();



return list;


}



public Student queryById(int id) {



Student student = yId(id);



return student;


}



public boolean saveStu(Student student) {



boolean b = u(student);



if(b){




return true;



}else{




return false;



}


}



public boolean updateStu(Student student) {



boolean b = Stu(student);



if(b){




return true;



}else{




return false;



}


}



public List dimStu(Student student) {



List list = (student);



return list;


}



public int getCountSize(Object obj) {



return ntSize(obj);


}



}



package e;



import



public interface UserService {


public boolean isLogin(Users user);


}



package



import o;


import


import rvice;



public class UserServiceImpl implements UserService {



private UserDao udao;



public void setUdao(UserDao udao) {



= udao;


}



public boolean isLogin(Users user) {



boolean b = n(user);



if(b){




return true;



}else{




return false;



}


}



}


6




编写< /p>


Action





package



import Context;


import Support;


import


import tService;


import rvice;



public class UserAction extends ActionSupport {



private UserService us;


private Users user;



public Users getUser() {



return user;


}



public void setUser(Users user) {



= user;


}



public UserService getUs() {



return us;


}



public void setUs(UserService us) {



= us;


}



public String Login() throws Exception {



String username = rname();



String password = sword();



boolean b = n(user);



if(b){




return



}else{




if((











text().put(


请输入用户名和密码!











}else if((











text().put(


请输入用户名


!










}else if((











text().put(


请输入密码!











}else{











text().put(


请检查用 户名和密码!











}




return



}






}



}



package



import



import rvletRequest;



import tActionContext;



import Context;


import Support;


import


import t;


import tService;



public class StudentAction extends ActionSupport {



private StudentService ss;


private int id;


private String username;


private String password;


private String phone;


private String email;


private String address;


private Student student;


private List list


private Page page ;


private final static int pagesize = 3;







private int countdate;//


总记录





public int getCountdate() {



return countdate;


}



public void setCountdate(int countdate) {



ate = countdate;


}



public static int getPagesize() {



return pagesize;


}



public Page getPage() {



return page;


}



public void setPage(Page page) {



= page;


}



public List getList() {



return list;


}



public void setList(List list) {



= list;


}



public Student getStudent() {



return student;


}



public void setStudent(Student student) {



t = student;


}



public int getId() {



return id;


}



public void setId(int id) {



= id;


}



public HttpServletRequest getRequest() {



return request;


}



public void setRequest(HttpServletRequest request) {



t = request;


}



public StudentService getSs() {



return ss;


}



public void setSs(StudentService ss) {



= ss;


}



public String getUsername() {



return username;


}



public void setUsername(String username) {



me = username;


}



public String getPassword() {



return password;


}



public void setPassword(String password) {



rd = password;


}



public String getPhone() {



return phone;


}



public void setPhone(String phone) {



= phone;


}



public String getEmail() {



return email;


}



public void setEmail(String email) {



= email;


}



public String getAddress() {



return address;


}



public void setAddress(String address) {



s = address;


}



HttpServletRequest request = uest();



public String queryAll() throws Exception {



List list = ll();



if(()==0){




text().put(


没有可以显示的数据!




}else{




text().put(



}



return


}



public String updateStu() throws Exception {



String username = rname();



String password = sword();



String phone = ne();



String email = il();



String address = ress();



rname(username);



sword(password);



ne(phone);



il(email);



ress(address);



boolean b = Stu(student);



if (b) {



< p>
text().put(


更新成功!





return ();



} else {




text().put(


更新失败!





return



}


}



public String queryById() throws Exception {



int id = ();



Student stu = yId(id);



text().put(



return


}



public String delete() throws Exception {



int id = ();



boolean b = (id);



if (b) {




text().put(


删除成功!





return ();



} else {




text(). put(


删除失败!





return



}


}



public String saveStu() throws Exception {



int id = ();



String username = rname();



String password = sword();



String phone = ne();



String email = il();



String address = ress();



(id);



rname(username);



sword(password);



ne(phone);



il(email);



ress(address);



boolean b = u(student);



if (b) {



< p>
text().put(


增加成功!





return ();



}



return


}



public String dimStu() throws Exception {



countdate = ntSize(new Student());



Student stu = new Student();



esize(3);



ntdate(countdate);



list = (student);



int id = 0;



(id);



text().put(



return


}


}


7




配置文件





xml


version


=



encoding


=



?>






<


beans


xmlns


=





xmlns:xsi


=




xmlns:aop


=





xmlns:tx


=< /p>





xsi:schemaLocation


=


< br>





/schema/beans


/schema/beans/spring- beans-







/schema/aop


/schema/aop/spring- aop-2.5.


xsd






/schema/tx


/schema/tx/


d


>

< br>







<


bean


id


=



class

< p>
=



ataSource


>


-


-


-


-


-


-


-


-



本文更新与2021-02-24 15:47,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/670473.html

SSI框架的一个简单小项目的相关文章

  • 爱心与尊严的高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊严高中作文题库

    1.关于爱心和尊严的作文八百字 我们不必怀疑富翁的捐助,毕竟普施爱心,善莫大焉,它是一 种美;我们也不必指责苛求受捐者的冷漠的拒绝,因为人总是有尊 严的,这也是一种美。

    小学作文
  • 爱心与尊重的作文题库

    1.作文关爱与尊重议论文 如果说没有爱就没有教育的话,那么离开了尊重同样也谈不上教育。 因为每一位孩子都渴望得到他人的尊重,尤其是教师的尊重。可是在现实生活中,不时会有

    小学作文
  • 爱心责任100字作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任心的作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文
  • 爱心责任作文题库

    1.有关爱心,坚持,责任的作文题库各三个 一则150字左右 (要事例) “胜不骄,败不馁”这句话我常听外婆说起。 这句名言的意思是说胜利了抄不骄傲,失败了不气馁。我真正体会到它

    小学作文