第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

使用Struts2+Hibernate開(kāi)發(fā)學(xué)生信息管理功能

  • hibernate 5.4.27 導(dǎo)入包更換:org.hibernate.boot.registry.StandardServiceRegistryBuilder; ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().applySettings(config .getProperties()).build();
    查看全部
    0 采集 收起 來(lái)源:生成表結(jié)構(gòu)

    2021-02-06

  • Hibernate 實(shí)體類關(guān)系映射 配置文件

    查看全部
  • Struts2與Hibernate整合:????
    1.?創(chuàng)建struts2和hibernate用戶類庫(kù)???
    2.?導(dǎo)入struts2與hibernate的jar包????
    3.?配置web.xml文件(加入struts2的過(guò)濾器)
    ??<filter>????????
    ???<filter-name>struts2</filter-name>????????
    ???<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>?//?struts2過(guò)濾器????
    ???</filter>????
    ???<filter-mapping>????????
    ??????<filter-name>struts2</filter-name>????????
    ??????<url-pattern>/*</url-pattern>??//?過(guò)濾所有請(qǐng)求????
    ???</filter-mapping>????
    4.?創(chuàng)建struts.xml?????
    ????WEB-INF/classes/struts.xml?-->?src/struts.xml?????
    ????<package?name="default"?namespace="/"?extends="struts-default"></package>????
    5.?配置hibernate.cfg.xml(hibernate的主配置文檔)????
    ????src/hibernate.cfg.xml??
    ????<hibernate-configuration>???
    ??????<session-factory>????
    ???????<property?name="connection.username">root</property>????
    ???????<property?name="connection.password"></property>????
    ???????<property?name="connection.driver_class">com.mysql.jbdc.Driver</property>????
    ???????<property?name="connection.url">jdbc:mysql:///test?useUnicode=true&amp;characterEncoding=UTF-8</property>
    ???????<property?name="dialect">org.hibernate.dialet.MySQLDialect</property>????
    ???????<property?name="show_sql">true</property>????
    ???????<property?name="format_sql">true</property>????
    ???????<property?name="hbm2dd1.auto">update</property>????
    ???????<property?name="hibernate.current_session_context_class">thread</property>//?使用getCurrentSession方式打開(kāi)會(huì)話???
    ??????</session-factory>??
    ????</hibernate-configuration>
    查看全部
    0 采集 收起 來(lái)源:Struts2與Hibernate整合

    2019-06-24

  • 重點(diǎn)? ?重點(diǎn)

    查看全部
    0 采集 收起 來(lái)源:Struts2與Hibernate整合

    2019-06-22

  • 實(shí)現(xiàn)修改學(xué)生資料action和頁(yè)面調(diào)用

    業(yè)務(wù)邏輯代碼:

    public boolean updateStudent(Student stu) {

    Transaction transaction=null;

    try{

    Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

    transaction=session.beginTransaction();

    session.update(stu);;

    transaction.commit();

    return true;

    }catch(Exception e){

    e.printStackTrace();

    return false;

    }finally{

    if(transaction!=null){

    transaction=null;

    }

    }

    }

    action代碼:

    public String save() throws ParseException{

    Student stu=new Student();

    stu.setSid(request.getParameter("sid"));

    stu.setSname(request.getParameter("sname"));

    stu.setGender(request.getParameter("gender"));

    SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");

    stu.setBirthday(sdf.parse(request.getParameter("birthday")));

    stu.setAddress(request.getParameter("address"));

    StudentDao sd=new StudentDaoImpl();

    sd.updateStudent(stu);

    return "save_success";

    }



    查看全部
  • 編寫(xiě)修改學(xué)生的業(yè)務(wù)代碼:

    動(dòng)作1——頁(yè)面顯示學(xué)生資料的動(dòng)作

    邏輯查詢:

    public Student queryStudentById(String sid) {

    Transaction transaction=null;

    Student s=null;

    try{

    Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

    transaction=session.beginTransaction();

    s=session.get(Student.class, sid);

    transaction.commit();

    return s;

    }catch(Exception e){

    e.printStackTrace();

    return s;

    }finally{

    if(transaction!=null){

    transaction=null;

    }

    }

    }

    Action動(dòng)作:

    public String modify(){

    String sid=request.getParameter("sid");

    StudentDao sd=new StudentDaoImpl();

    Student s=sd.queryStudentById("sid");

    session.setAttribute("student_modify", s);

    return "student_modify_success";

    }

    頁(yè)面顯示學(xué)生資料:

    <form name="modifyForm" action="<%=path%>/students/Students_save.action" method="post">

    <table width="400" >

    ? <tr>

    ? ? <td width="30%">學(xué)號(hào):</td>

    ? ? <td><input type="text" name="sid" value='<s:property value="#session.student_modify.sid"/>' ?readonly="readonly"/></td>

    ? </tr>

    ? <tr>

    ? ? <td width="30%">姓名:</td>

    ? ? <td><input type="text" name="sname" value='<s:property value="#session.student_modify.sname"/>'/></td>

    ? </tr>

    ? <tr>

    ? ? <td>性別:</td>

    ? ? <td>

    ? ? ? <s:if test='%{#session.student_modify.gender=="男"}'>

    ? ? ? ? ?<input type="radio" name="gender" value="男" checked="checked"/>男

    ? ? ? ? ?<input type="radio" name="gender" value="女"/>女

    ? ? ? </s:if>

    ? ? ? <s:else>

    ? ? ? ? ?<input type="radio" name="gender" value="男" />男

    ? ? ? ? ?<input type="radio" name="gender" value="女" checked="checked"/>女

    ? ? ? </s:else>

    ? ? ? </td>

    ? </tr>

    ? <tr>

    ? ? <td>出生日期:</td>

    ? ? <td><input name="birthday" type="text" id="control_date" size="20"

    ? ? ? maxlength="10" onclick="new Calendar().show(this);" readonly="readonly"?

    ? ? ? value="<s:date name="#session.student_modify.birthday" format="yyyy-MM-dd"/>"

    ? ? ? />

    ? ? </td>

    ? </tr>

    ? <tr>

    ? ? <td>地址:</td>

    ? ? <td><input type="text" name="address" value='<s:property value="#session.student_modify.address"/>'/></td>

    ? </tr>

    ? <tr>

    ? ? <td colspan="2" align="center"><input class="button" type="submit" value="修改"></td>

    ? </tr>

    </table>

    </form>




    動(dòng)作2——保存修改后的學(xué)生資料的動(dòng)作



    查看全部
  • 修改學(xué)生資料

    介紹:通過(guò)點(diǎn)擊學(xué)生姓名,跳轉(zhuǎn)到需改頁(yè)面,涉及技術(shù)(信息回顯),注意:學(xué)生學(xué)號(hào)不能修改,回顯的信息是從數(shù)據(jù)庫(kù)中查出來(lái)的

    1、界面原型演示

    2、編寫(xiě)修改學(xué)生業(yè)務(wù)邏輯代碼

    3、編寫(xiě)修改action

    4、頁(yè)面調(diào)用

    查看全部
  • 添加學(xué)生的方法

    提交事物:是為了下次開(kāi)啟事物,可以正常執(zhí)行。

    public boolean addStudent(Student stu) {

    Transaction transaction=null;

    try{

    Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

    transaction=session.beginTransaction();

    stu.setSid(this.getNewSid());

    session.save(stu);

    transaction.commit();

    return true;

    }catch(Exception e){

    e.printStackTrace();

    return false;

    }finally{

    if(transaction!=null){

    transaction=null;

    }

    }

    }


    查看全部
  • 添加學(xué)生信息

    1、學(xué)生主鍵生成策略:學(xué)生sid是字符串類型,每次由系統(tǒng)自動(dòng)生成。

    額外編寫(xiě)生成學(xué)生學(xué)號(hào)的方法:該方法功能——是去掉學(xué)號(hào)前的S,剩下轉(zhuǎn)換為數(shù)字,轉(zhuǎn)換成數(shù)字之后+1,之后再還原拼成8位的學(xué)生編號(hào)。

    //獲得學(xué)生主鍵最大值,并且進(jìn)行加1操作。

    public String getNewSid(){

    Transaction transaction=null;

    String hql="";

    String sid=null;

    try{

    Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

    transaction=session.beginTransaction();

    hql="select max(sid) from Student";

    Query query=session.createQuery(hql);

    sid=(String)query.uniqueResult(); ?

    if(sid==null||"".equals(sid)){

    sid="S00000001";

    }else{

    int i=Integer.parseInt(sid.substring(1));

    i++;

    String temp=String.valueOf(i);

    int length=temp.length();

    for(int j=0;j<=7-length;j++){

    temp="0"+temp;

    }

    sid="S"+temp;

    }

    return sid;

    }catch(Exception e){

    e.printStackTrace();

    return null;

    }finally{

    if(transaction!=null){

    transaction=null;

    }

    }

    }

    2、編寫(xiě)添加學(xué)生業(yè)務(wù)邏輯代碼

    查看全部
  • 添加學(xué)生資料——實(shí)現(xiàn)步驟和界面原型設(shè)計(jì)

    1、界面原型設(shè)計(jì)

    2、編寫(xiě)添加學(xué)生業(yè)務(wù)邏輯代碼

    3、編寫(xiě)添加action

    4、頁(yè)面調(diào)用


    查看全部
  • 刪除學(xué)生資料

    一:界面調(diào)用


    <td><a href="<%=path %>/students/Student_delete?sid=<s:property value="#stu.sid"/>" onclick="javascript: return confirm('確認(rèn)刪除嗎?');">刪除</a></td>


    二:編寫(xiě)業(yè)務(wù)邏輯代碼


    public boolean deleteStudent(String sid) {

    // TODO Auto-generated method stub

    Transaction transaction=null;

    try{

    Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

    Student stu=(Student)session.get(Student.class, sid);

    session.delete(stu);

    transaction.commit();

    return true;

    }catch(Exception e){

    e.printStackTrace();

    return false;

    }finally{

    if(transaction!=null){

    transaction=null;


    }

    }

    }



    三:編寫(xiě)刪除action

    public String delete(){

    String sid=request.getParameter("sid");

    sd.deleteStudent(sid);

    return "student_delete_success";

    }



    四:測(cè)試

    ? ? <result name="student_delete_success" type="chain">Student_query</result>



    查看全部
    0 采集 收起 來(lái)源:刪除學(xué)生資料

    2019-05-11

  • 頁(yè)面調(diào)用與數(shù)據(jù)展示

    步驟1修改tree.jsp訪問(wèn)action的路徑由于樹(shù)形菜單打開(kāi)方式,通過(guò)框架方式來(lái)打開(kāi)。

    步驟2:Students_query_success.jsp中添加struts標(biāo)簽<%@ taglib prefix="s" uri="/struts-tags"%>,因?yàn)橛玫?lt;s:iterator>標(biāo)簽來(lái)遍歷學(xué)生,其中該標(biāo)簽用到兩個(gè)屬性,value屬性:從哪里獲得要遍歷的集合,這里采用ognl表達(dá)式,struts的值棧分為對(duì)象棧和上下文棧,我們放到session中,其實(shí)是放到上下文棧中,從上下文棧中獲取數(shù)據(jù)必須以#開(kāi)頭例如:value="#session.student_list"另外一個(gè)屬性var:表示集合中取出每一個(gè)對(duì)象的名字。

    每一個(gè)對(duì)象的屬性用<s:property value="#stu.sid">來(lái)表示,(說(shuō)明:

    每次遍歷,將session中的list的值取出一個(gè)放到對(duì)象stu中,然后從stu中取出Student類的信息。)

    出生日期:用中文格式顯示,可以用struts格式化日期標(biāo)簽<s:date name

    ="#stu.birthday" format="yyyy年MM月dd日/>(format等同于SimpleDateFormat)

    查看全部
  • 設(shè)計(jì)學(xué)生Action類(action包中創(chuàng)建StudentAction類并編寫(xiě)action方法來(lái)執(zhí)行查詢所有學(xué)生的方法)

    action方法:

    public String query(){

    StudentDao sd=new StudentDaoImpl();

    List<Student> list=sd.queryAllStudent();

    if(list!=null&&list.size()>0){

    session.setAttribute("student_list", list);

    }

    return "student_query_success";

    }

    struts.xml:業(yè)務(wù)分層原理,所以重新創(chuàng)建package,登陸是登陸,學(xué)生管理是學(xué)生管理的package。

    ?<package name="student_manage" namespace="/users" extends="struts-default">

    ? ? <action name="*_*" method="{2}" class="action.{1}Action">

    ? ? <result name="student_query_success">/students/Students_query_success.jsp</result>

    ? ? </action>

    ? ? </package>



    查看全部
  • 學(xué)生業(yè)務(wù)邏輯接口實(shí)現(xiàn)

    查詢所有學(xué)生方法

    public List<Student> queryAllStudent() {

    Transaction transaction=null;

    String hql="";

    List<Student> list=null;

    try{

    Session session=MyHibernateSessionFactory.getSessionFactory().getCurrentSession();

    transaction=session.beginTransaction();

    hql="from Student";

    Query query=session.createQuery(hql);

    list=query.list();

    transaction.commit();

    return list;

    }catch(Exception e){

    e.printStackTrace();

    return list;

    }finally{

    if(transaction!=null){

    transaction=null;

    }

    }

    }

    test方法

    @Test

    public void testAddAllStudent(){

    StudentDao sd=new StudentDaoImpl();

    List<Student> studentList=sd.queryAllStudent();

    for(int i=0;i<studentList.size();i++){

    System.out.println(studentList.get(i));

    }

    }



    查看全部
  • 設(shè)計(jì)學(xué)生業(yè)務(wù)邏輯接口(包括學(xué)生的增刪改查的抽象方法)

    添加學(xué)生:

    public abstract boolean addStudent(Student s);

    刪除學(xué)生:

    public abstract boolean deleteStudent(String sid)

    修改學(xué)生:

    public abstract boolean updateStudent(Student stu);

    查詢學(xué)生:
    public abstract List<Student> queryAllStudent();

    public abstract Student queryStudentById(String sid);



    查看全部
  • 學(xué)生管理模塊

    一、顯示學(xué)生資料

    實(shí)現(xiàn)步驟:1、添加測(cè)試數(shù)據(jù)(TestStudent類中添加測(cè)試方法TestSaveStudent)

    目的:在該方法中添加幾條數(shù)據(jù),查看是否能插入數(shù)據(jù)庫(kù),從而驗(yàn)證我們創(chuàng)建生成的student表是否可以進(jìn)行操作。


    ? ? ? ? ? ? ? ? ?2、設(shè)計(jì)學(xué)生業(yè)務(wù)邏輯接口

    ? ? ? ? ? ? ? ? ?3、設(shè)計(jì)學(xué)生業(yè)務(wù)邏輯接口實(shí)現(xiàn)類

    ? ? ? ? ? ? ? ? ?4、設(shè)計(jì)學(xué)生Action類

    ? ? ? ? ? ? ? ? ?5、頁(yè)面調(diào)用

    ? ? ? ? ? ? ? ? ?6、顯示數(shù)據(jù)

    2、刪除學(xué)生資料

    3、學(xué)生主鍵生成策略

    4、添加學(xué)生資料

    5、修改學(xué)生資料


    查看全部
  • 表單驗(yàn)證功能(登陸表單上顯示報(bào)錯(cuò)信息)

    方式一:客戶端(前端界面JavaScript)完成。

    方式二:服務(wù)器端(后端struts的驗(yàn)證框架)完成。

    如果出錯(cuò),則返回登陸界面,并在表單上提示出錯(cuò)信息。

    步驟1:重寫(xiě)從Actionsupport繼承的validate()方法。

    addFieldError(key名,錯(cuò)誤提示信息):提示錯(cuò)誤信息的方法。

    注意:validate()方法會(huì)對(duì)Action中所有方法進(jìn)行驗(yàn)證,只對(duì)登陸進(jìn)行驗(yàn)證,注銷(xiāo)不需要進(jìn)行表單驗(yàn)證,所以在注銷(xiāo)方法上加@SkipValidation注解,保證執(zhí)行注銷(xiāo)方法時(shí)不對(duì)表單進(jìn)行驗(yàn)證。

    public void validate() {

    if("".equals(user.getUsername().trim())){

    addFieldError("usernameError", "用戶名不能為空");//錯(cuò)誤字段提示信息

    }

    if((user.getPassword()).length()<6){

    addFieldError("passwordError","密碼不能小于6位");

    }

    }

    步驟2:

    加入struts核心標(biāo)簽庫(kù)<%@ taglib prefix="s" uri="/struts-tags"%>

    加入

    <div>

    ?<s:fielderror/> <!-- 顯示表單驗(yàn)證的出錯(cuò)信息 -->

    </div>


    查看全部
首頁(yè)上一頁(yè)1234567下一頁(yè)尾頁(yè)

舉報(bào)

0/150
提交
取消
課程須知
各位小伙伴,學(xué)習(xí)本課程前需要對(duì) Struts2和Hibernate的基礎(chǔ)知識(shí)有所了解。
老師告訴你能學(xué)到什么?
1、掌握Struts2和Hibernate的整合開(kāi)發(fā) 2、能夠使用Struts2+Hibernate獨(dú)立開(kāi)發(fā)信息管理類的項(xiàng)目,進(jìn)行數(shù)據(jù)的增刪改查。

微信掃碼,參與3人拼團(tuán)

微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)

友情提示:

您好,此課程屬于遷移課程,您已購(gòu)買(mǎi)該課程,無(wú)需重復(fù)購(gòu)買(mǎi),感謝您對(duì)慕課網(wǎng)的支持!