S关于SH整合
一直在忙乱七八糟的,SSH貌似还有很多不知道给大家看看我的[local]1[/local]这是我的结构图
我现在发现,我不知道怎么分配任务了,不知道怎么整合他们,有没有整个的例子,或者书籍,视频也行。目前等于三个框架的jar都已拥有进来了
struts测试
程序代码:
<action name="test" class="com.joker.action.ActionDemo1" method="Demo1"> <result name="success">index.jsp</result> <result name="error">error.jsp</result> </action>
hibernate测试
程序代码:
package com.joker.test; import org.hibernate.cfg.Configuration; import org.hibernate.tool.hbm2ddl.SchemaExport; public class HibernateTest { public static void main(String a[]){ Configuration cfg = new Configuration().configure(); SchemaExport se = new SchemaExport(cfg); se.create(true, true); } }
spring测试
程序代码:
package com.joker.test; import java.sql.Connection; import java.sql.ResultSet; import java.sql.Statement; import javax.sql.DataSource; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; public class MySpring { public static void main(String[] args) throws Exception { @SuppressWarnings("resource") ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml"); DataSource ds = ac.getBean("dataSource",DataSource.class); String sql = "select * from user"; Connection conn = ds.getConnection(); Statement stat = conn.createStatement(); ResultSet rs = stat.executeQuery(sql); while(rs.next()){ String name = rs.getString(2); String pswd = rs.getString(3); String vips = rs.getString(4); System.out.println(vips); System.out.println(name); System.out.println(pswd); } } }
都运行成功了!, 然后我不知道干嘛了,因为spring没怎么学,不知道怎么用,其它两个还行。