ITeye博客

SSH

共 6 篇文章

使用spring的OpenEntityManagerInView

OpenEntityManagerInView和Hibernate的OpenSessionInView一样,服务端在接收到一个请求的时候开启EntityManager,在请求结束的时候才去关闭这个EntityManager,和JpaDaoSupport一起可以很好地工作。 使用OpenEntityManagerInView可以解决JPA延迟加载出现的LazyInitialize异常。如果不使用JPA的OpenEntityManagerInViewFilter,那么当使用玩getJpaTemplate().persist()或者remove()方法后,Spring就会自动关闭EntityMan…

2011-08-04 10:09 · SSH · Spring · JPA · EntityManager · openentitymanagerinview

原来这样读取属性文件的内容呀

public class SiteUrl { public static String readUrl(String key){ Properties properties = new Properties(); try { properties.load(SiteUrl.class.getClassLoader().getResourceAsStream("siteurl.properties")); } catch (IOException e) { e.printStackTrace(); } return (String)properties.getProperty(key); } }

2011-03-13 11:08 · SSH

验证上传的文件是否允许

/*** * 验证上传的文件是否允许 * @param forefile * @return */ public static boolean validateFileType(FormFile formfile){ if(formfile != null && formfile.getFileSize() > 0){ List<String> arrowType = Arrays.asList("image/gif","image/jpg","image/bmp","image/png","image/jpeg","image/pjpeg" ,"application/x-shockwav…

2011-03-12 20:45 · SSH · EXT · Flash · Excel

验证图片上传

/*** * 验证图片上传 * @param forefile * @return */ public static boolean validateImageFileType(FormFile formfile){ if(formfile != null && formfile.getFileSize() > 0){ List<String> arrowType = Arrays.asList("image/gif","image/jpg","image/bmp","image/png","image/jpeg","image/pjpeg"); String ext = formfile.…

2011-03-12 20:44 · SSH · EXT

Struts与Spring结合的3种实现方式

1、 使用WebApplicationContext:这种方式是在Struts的Action类中获取Spring应用上WebApplicationContext的实例化对象,通过此对象调用Bean。 2、 继承Spring的ActionSupport:这种方式实际上是对第一种方式的一种简化,当Struts的Action类继承了Spring的ActionSupport以后,直接可以使用WebApplicationContext对旬,从而简化对Spring应用上下文的操作。 3、 将Struts的Action托管给Spring:这种方式将Struts的Action以Bean的形式托管给Sprin…

2011-02-23 14:49 · SSH · Spring · Struts · IOC · Bean

JPA 批注参考

1 JPA 批注参考 版本: 5/12/06 作为 Java 企业版 5 (Java EE 5) Enterprise Java Bean (EJB) 3.0 规范的组成部分,Java 持续性 API (JPA) 显著简化了 EJB 持续性并提供了一个对象关系映射方法,该方法使您可以采用声明方式定义如何通过一种标准的可移植方式(在 Java EE 5 应用服务器内部以及 Java 标准版 (Java SE) 5 应用程序中的 EJB 容器外部均可使用)将 Java 对象映射到关系数据库表。 在 JPA 之前,Java EE 应用程序将持续类表示为容器管理的实体 bean。使用 JPA,您可以…

2010-12-02 10:44 · SSH · Java · JPA · EJB · 企业应用 · Bean