J2EE 学习笔记

一实现Hi实例

1 建立可才持久化类

2 创建映射文件

3 创建配置文件

4 创建测试类

二S2 Hello

1 在struts.xml增加HelloAction的配置

2 HelloAction类的创建

3 succes.jsp页面

 

1.1 <action name="hello"  class="str.HelloAction" > action的url             

  <result name="success">Txindex.jsp</result> success指向配置 

  </action>

三Servlet

1生命周期

2路径配置

3请求控制器

 

四Jdbc

连接信息

public static final String DBDRIVER = "com.mysql.jdbc.Driver" ;

public static final String DBURL = "jdbc:mysql://localhost:3306/temp" ;

public static final String DBUSER = "root" ;

public static final String DBPASS = "wdj3166" ;

更新

UPDATE news SET title=?,"+"content=?,"+"auther=? WHERE id=?

删除

DELETE FROM news WHERE id=?

插入

INSERT INTO user (name,Email,content,author) VALUES(?,?,?,?)

简单模糊查询

select * from news where title like '%+title+%' or content like '%+conten+t%' or author like '%+auther+%'

 

五Hi配置文件

<hibernate-configuration>

    <session-factory>

    <!-- 数据库连接设置 -->

     

        <property name="connection.url">jdbc:mysql://localhost:3306/test? useUnicode=true ; characterEncoding=utf-8</property>

        <property name="connection.username">root</property>

        <property name="connection.password">wdj3166</property>

        <property name="connection.driver_class">com.mysql.jdbc.Driver</property>

    <!-- Sql方言 -->

       <property name="dialect">org.hibernate.dialect.MySQLDialect</property>

          <property name="show_sql">true</property>

       <!--映射资源  -->

       <mapping resource="com/hibernate/User.hbm.xml" />

    </session-factory>

</hibernate-configuration>

 

六S2配置文件

<struts>

<!-- 加入默认的struts2 默认配置文件 -->

<include file="struts-default.xml"/>

<package name="default"  extends="struts-default">

<!--

<action name="hello"  class="str.HelloAction" > action的url             

<result name="success">Txindex.jsp</result> success指向配置 

</action>

-->

<!-- 自定义验证拦截器 -->

<interceptors>

<interceptor name="LoginAction" class="filter.LoginYz"></interceptor>

</interceptors>

<global-results><!-- 公共result -->

<result name="login" type="redirect">index.jsp</result>

</global-results>

<!-- 添加受验证拦截器保护的Action -->

<action name="Welcome">

<interceptor-ref name="LoginAction"></interceptor-ref>

<result name="success">welcome.jsp</result>

</action>

<action name="Login"  class="str.LoginAction" >         

<result name="success">index.jsp</result> 

</action>

</package>

</struts>

 

七Jdbc示例

建立数据库及表

使用jdbc操作数据库CRUD

八Jsp实例

Java + Html

 

九io流

根据流动的方向:分为输入流与输出流(I/O)

 根据流动的内容:分为字节流与字符流

输入流 InputStream  Reader

输出流 OutputStream Writer

流是程序和外界进行数据交换的通道,在oop中都表现为一种对象.(数据集合看作对象)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值