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

為了賬號安全,請及時綁定郵箱和手機立即綁定

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

  • 完成顯示登陸成功顯示用戶名:

    1、返回登陸成功頁面前,在session中保存登陸成功的用過戶名。

    Action中l(wèi)ogin方法:session.getAttribute("loginUserName",user.getUsername());

    前端頁面獲取方式:

    JSPsession獲取方式:<%=session.getAttribute("loginUserName"%>

    EL表達式獲取方式:${sessionScope.loginUserName}

    注銷功能:編寫注銷方法(判斷session中是否保存了用戶登錄成功的用戶名,如果有則清空,然后返回一個字符串注銷標識,緊接著配置struts.xml)

    session的removeAttribute(""):移除指定key的value。


    查看全部
  • 設計所有Action父類:

    1、繼承ActionSupport:內置很多struts攔截器,方便以后使用。

    2、獲得常用的內置對采用偶合IOC方式注入屬性,以至于與前端進行聯系,

    實現ServletRequestAware、ServletResponseAware、ServletContext、并通過方法為request、response、application、session(通過request.getSession())賦值。

    查看全部
  • struts2的三種接收表單數據的方式

    查看全部
  • 對象關系映射文件

    查看全部
  • 最新API方法:

    Configuration configuration = new Configuration().configure(); ServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build(); SessionFactory sessionfactory = configuration.buildSessionFactory(registry); Session session = sessionfactory.getCurrentSession(); MetadataImplementor metadata = (MetadataImplementor) new MetadataSources(registry).buildMetadata(); SchemaExport export = new SchemaExport(registry,metadata); export.create(true,true);



    查看全部
    1 采集 收起 來源:生成表結構

    2018-12-01

  • 生成表結構://?創(chuàng)建配置對象Configuration?config?=?new?Configuration().configue();//?創(chuàng)建服務注冊對象ServiceReqistry?serviceReqistry?=?new?ServiceRegistryBuilder().applySetting(config);//?創(chuàng)建sessionFactorySessionFactory?sessionFactory?=?config.buildeSessionFactory(serviceReqistry);//?創(chuàng)建session對象Session?session?=?sessionFactory.getCurrentSession();//?創(chuàng)建schemaExport對象SchemaExport?export?=?new?SchemaExport(config);?export.create(true,?true);?//?第一個true表示生成表結構,第二個表示輸出SQL語句

    查看全部
    1 采集 收起 來源:生成表結構

    2018-12-01

  • 靜態(tài)方法不能獲取非靜態(tài)屬性

    查看全部
  • private?static?SessionFactory?sessionFactory;??//?會話工廠屬性
    //?構造方法私有化,保證單例模式
    private?MyHibernateSessionFactory(){}
    //?公有的靜態(tài)方法,獲得會話工廠對象
    public?static?SessionFactory?getSessionFactory(){
    ????if(sessionFactory==null){
    ????????Configuration?config?=?new?Configuration().configure();
    ????????ServiceReqistry?serviceReqistry?=?new?ServiceReqistryBuilder().applySettings(config.getProperties()).buildServiceReqistry();
    ????????sessionFactory?=?config.buildSessionFactory(serviceReqistry);
    ????????return?sessionFactory;
    ????}?else{
    ????????return?sessionFactory;
    ????}
    }


    查看全部
  • 生成表結構:
    //?創(chuàng)建配置對象
    Configuration?config?=?new?Configuration().configue();
    //?創(chuàng)建服務注冊對象
    ServiceReqistry?serviceReqistry?=?new?ServiceRegistryBuilder().applySetting(config);
    //?創(chuàng)建sessionFactory
    SessionFactory?sessionFactory?=?config.buildeSessionFactory(serviceReqistry);
    //?創(chuàng)建session對象
    Session?session?=?sessionFactory.getCurrentSession();
    //?創(chuàng)建schemaExport對象
    SchemaExport?export?=?new?SchemaExport(config);
    
    export.create(true,?true);?//?第一個true表示生成表結構,第二個表示輸出SQL語句


    查看全部
    2 采集 收起 來源:生成表結構

    2018-09-11

  • 實體類的映射文件

    https://img1.sycdn.imooc.com//5b9733990001c75e19201080.jpg

    查看全部
  • Struts2與Hibernate整合:
    ????1.?創(chuàng)建struts2和hibernate用戶類庫
    ????2.?導入struts2與hibernate的jar包
    ????3.?配置web.xml文件(加入struts2的過濾器)
    ????<filter>
    ????????<filter-name>struts2</filter-name>
    ????????<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>?//?struts2過濾器
    ????</filter>
    ????<filter-mapping>
    ????????<filter-name>struts2</filter-name>
    ????????<url-pattern>/*</url-pattern>??//?過濾所有請求
    ????</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方式打開會話
    ???</session-factory>
    ??</hibernate-configuration>


    查看全部
  • 修改學生資料

    注意:學號不能修改

    查看全部
  • 說明:每次遍歷。將session中的list的值取出一個放到對象stu中,然后從stu中取出Student類的信息。

    查看全部
  • 加入驗證方法后, 輸入不合法的會報錯,

    No result defined for action action.UsersAction and result input - action - file:/D:/InstallSoft/Apache%20Software%20Foundation/Tomcat%207.0/webapps/imooc_sh/WEB-INF/classes/struts.xml:11:59

    解決方法:在struts2配置文件中配置下

    <result name="input">/users/Users_login.jsp</result>

    原理:input是struts默認的邏輯視圖名稱,表示當前頁面輸入參數驗證錯誤時,會自動返回要跳轉的頁面。 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?


    查看全部
  • 配置hibernate.cfg.xml
    查看全部

舉報

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

微信掃碼,參與3人拼團

微信客服

購課補貼
聯系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

友情提示:

您好,此課程屬于遷移課程,您已購買該課程,無需重復購買,感謝您對慕課網的支持!