`
windmerlin
  • 浏览: 4412 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

Struts + Spring + Hibernate针对Oracle9i使用Bloc

    博客分类:
  • J2EE
阅读更多

   applicationContext.xml文件

 

<!-- lobHiandler,Oracle9i使用 -->
 <bean id="lobHandler" lazy-init="true"
  class="org.springframework.jdbc.support.lob.OracleLobHandler">
  <property name="nativeJdbcExtractor">
   <ref bean="nativeJdbcExtractor" />
  </property>
 </bean>
 
 <bean id="nativeJdbcExtractor" lazy-init="true"
  class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor" />

<!-- 配置sessionFactory -->
 <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  <property name="configLocation">
   <value>classpath:hibernate.cfg.xml</value>
  </property>
  <property name="lobHandler" ref="lobHandler"/>
 </bean>

 

     ActionForm和POJO都改为byte[] , Hibernate会自动映射为Blob字段

 

/**
  * 显示图片
  * @param mapping
  * @param form
  * @param request
  * @param response
  * @return null 
  * @throws Exception
  */

 public ActionForward disPic(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response)
   throws Exception {
  
  //获取容器
  ProjectManagerService proService = (ProjectManagerService)getBean("projectServiceImpl");

  //得到ID
  String id = request.getParameter("id").trim();
  String img = request.getParameter("img").trim();

  //根据ID查询对象
  ProjectManager proManager = proService.searchID(id);

  //判断显示头像还是指纹
  byte[] blob = null;
  if("photo".equals(img)){
   blob = proManager.getPhoto();
  }
  if("finger".equals(img)){
   blob = proManager.getFinger_mark();
  }
  

  //这里用的是ServletOutputStream;
   ServletOutputStream out = response.getOutputStream();
     out.write(len);
  return null;
 }

 

1
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics