spring2.0+hibernate3.0+struts1.x的个人总结

作者在 2010-06-12 20:48:17 发布以下内容
hibernate总结
只要把关系知道后,在xml文件里知道怎么配置就可以了
struts总结
在jsp页面中要加一个
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
因在验证的时候要用到<html:errors property=""/>
在写form表彰的时候,action=“<%=path%>/传过去的值.do”
struts——config.xml的配置
<form-beans>
<form-bean name="名字" type="写form的全路径"></form-bean>
</form-beans>
<action path="/表单传过来"  parameter="第二种action方法才要" type="action的路径" name="from——bean的名字">
<forward name="action返回来的值" type="/要跳传的页面"/>
</action>
action的两种方法
一是:写一个功能写一个action类,让这个类继承action接口
二是:写一个DisMappingAction类,继承MappingDispatchAction
  把一个功能写成一个方法。然后在xml文件中加parameter="方法名"
form的写法
 写一个表单写一个form类,让里面的属性要和表单里面的字符要一样
 在生成get/set方法
 里面有一个validate方法,是用来验证的。
 如果用到这个,那么在struts——config.xml文件中要加字段,
 validate="true" input="/出错转向页面"
 spring
 只总结事物的这块。
 在dao的时候要这样子写
 :new HiberSession().getcurr().save(st);
 在重新写一个方法,继承MethodInterceptor
 按照事物 的写法,
 Session session=null;
  Transaction tn=null;
  Object object=null;
   try {
   session=new HiberSession().getcurr();
    tn=session.beginTransaction();
    object=arg0.proceed();
    tn.commit();
    return object;
  } catch (Exception e) {
   e.printStackTrace();
   tn.rollback();
   return null;
  }
在写一个xml文件
里面最重要的一个bean是
<bean id="proxy" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.yds.dao.StudentDao</value>//就是dao的接口
</property>
<property name="target" ref="dao"></property>//dao的实现类
<property name="interceptorNames">
<list>
<value>adive</value>//就是上面的aop写法类
</list>
</property>
</bean>
因为在biz中要用到这个bean所以在bean中这样写
<bean id="biz" class="com.yds.biz.impl.StudentBizimpl">
<property name="sd">
<ref local="proxy"/>
</property>
</bean>
 同时在,action的类中。就要加上
 ApplicationContext ac=new ClassPathXmlApplicationContext("spring的xml文件路径");
 biz接口=(biz接口)ac.getBean("biz");
Spring | 阅读 1010 次
文章评论,共1条
源本英明C
2010-06-17 14:05
1
haha
游客请输入验证码
浏览275823次