读书人

(SSH框架)Spring 跟Struts的配置说明

发布时间: 2012-11-01 11:11:32 作者: rapoo

(SSH框架)Spring 和Struts的配置说明...

Struts2的配置:

?Spring的配置(applicationContext.xml):

?

Spring?下的测试:

public class BuygoodTest extends TestCase {public void testAdd(){//Spring deconstrustionBeanFactory factory= new ClassPathXmlApplicationContext("ApplicationContext.xml");BuygoodsDao dao=(BuygoodsDao)factory.getBean("buygoodsDao");// Time Format SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");Calendar calendar = Calendar.getInstance();String endtime=Integer.toString(calendar.get(Calendar.YEAR))+"-"+Integer.toString(calendar.get(Calendar.MONTH)+9)+"-"+Integer.toString(calendar.get(Calendar.DAY_OF_MONTH));//Hibernate  methodConfiguration cfg = new Configuration().configure();SessionFactory factory1 = cfg.buildSessionFactory();Session session = factory1.openSession();//Get Object by IdEbaySortinfo ebaySortinfo=(EbaySortinfo)session.get(EbaySortinfo.class,"263");EbayUserinfo ebayUserinfo=(EbayUserinfo)session.get(EbayUserinfo.class,"1");EbayBuygoods ebayBuygoods=new EbayBuygoods();ebayBuygoods.setBAble("0");ebayBuygoods.setBContent("Entiry New Brandxx");ebayBuygoods.setBEndtime(endtime);ebayBuygoods.setBName("THC");ebayBuygoods.setBPrice("18.00");ebayBuygoods.setBQuantity("10");ebayBuygoods.setCreatetime(sdf.format(new Date()));ebayBuygoods.setEbaySortinfo(ebaySortinfo);ebayBuygoods.setEbayUserinfo(ebayUserinfo);dao.addBuyinglead(ebayBuygoods);}

??

?

1 楼 shishuang 2011-06-28 [size=large][/size] 没有出来你struts 那个版本, 还有所需要的jar包 , 也一块写出来啊。 2 楼 danielhjd 2011-06-28 shishuang 写道[size=large][/size] 没有出来你struts 那个版本, 还有所需要的jar包 , 也一块写出来啊。
呵呵 你可以产看我的早前的博客:SHH框架下Struts的配置 上面有所有需要的JAR包。。希望对你有用

读书人网 >编程

热点推荐