随笔分类 - Java
关于Spring事务<tx:annotation-driven/>的理解(Controller可以使用@Transactional)
摘要:在使用SpringMvc的时候,配置文件中我们经常看到annotation-driven 这样的注解,其含义就是支持注解,一般根据前缀 tx、mvc 等也能很直白的理解出来分别的作用。 就是支持事务注解的(@Transactional) 、 就是支持mvc注解的,说白了就是使Controller中可...
阅读全文
整合Struts2与Spring
摘要:一、需要的JAR文件为:Spring和Struts2框架本身需要的JAR文件以及他们所依赖的JAR文件二、在web.xml中增加WebApplicationContext的相应配置,以下两种配置方式本质是一样的。1. Servlet 2.3及以上版本可以使用监听器,相应配置如下: ...
阅读全文
Cannot locate the chosen ObjectFactory implementation: spring
摘要:错误信息:Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location] at org.apache.struts2.config.AbstractBeanSelectionP...
阅读全文
generator自动生成mybatis配置和类信息
摘要:generator自动生成mybatis的xml配置、model、map等信息: 1、下载mybatis-generator-core-1.3.2.jar包。 网址:http://code.google.com/p/mybatis/downloads/list?can=3&q=Product%3D...
阅读全文
Java截取图片的一部分并保存为40*40的图片
摘要:@Test public void testImag() { try { String path = "E:/flower2.jpg"; int x = 11, y = 20, cutW = 280, cutH = 280; ...
阅读全文
HQL查询中取个别几个字段
摘要:数据表:要求:查询type为4001,以content分组,本计算不重复的pcInfoIdMySQL语句:SELECT COUNT(DISTINCT pcInfoId) AS COUNT,content,TIME FROM vrv_paw_reportlog WHERE TYPE='4001' GR...
阅读全文
在Hibernate中使用原生SQL语句
摘要:使用原生SQL查询必须注意:程序必须选出所有的数据列才可被转换成持久化实体。假设实体在映射时有一个<many-to-one../>的关联指向另外一个实体,则SQL查询中必须返回该<many-to-one../>映射的外键列,否则将导致抛出"column not found"异常。最简单的做法是,在S
阅读全文
Project facet Java version 1.8 is not supported.
摘要:Eclipse中添加项目到Servers中时提示“Project facet Java version 1.8 is not supported.”解决方案:方法一:选中项目,右键roperties》选择 Project Facets,右击选择 Java , Change Version 即可方法二...
阅读全文
Project facet Java 1.8 is not supported by target runtime Apache Tomcat v7.0.
摘要:找到项目下的“.settings”打开“org.eclipse.wst.common.project.facet.core.xml”文件删除掉“”
阅读全文
net.paoding.analysis.exception.PaodingAnalysisException: dic home should not be a file, but a directory!
摘要:Caused by: net.paoding.analysis.exception.PaodingAnalysisException: dic home should not be a file, but a directory! at net.paoding.analysis.knife.P...
阅读全文
filter-mapping中的dispatcher使用
摘要:web.xml里中的作用 2.4版本的servlet规范在部属描述符中新增加了一个元素,这个元素有四个可能的值:即 REQUEST,FORWARD,INCLUDE和ERROR可以在一个元素中加入任意数目的,使得filter将会作用于直接从 客户端过来的request,通过forward过来的requ...
阅读全文
HQL查询语句中的模糊查询
摘要:From Person this Where this.name like '%abc%'@SuppressWarnings("unchecked") @Override public List query(String type) { return getSession...
阅读全文
将C语言的CRC32 代码转成JAVA的CRC32 代码
摘要:public class CustomerCRC32 { private static long[] crc32Table = new long[256]; static { long crcValue; for (int i = 0; i > 1; ...
阅读全文
在拼接字符串中常常因空字符串导致截取报错的技巧
摘要:String areaRange = " ";// 这里设置一个带空格的空字符串,其长度就为1,这样在下面的截取字符串时就不会因空字符报超出长度了 for (Area tempArea : areas) { ar...
阅读全文
Hibernate主键生成器
摘要:主键生成器负责生成数据表记录的主键:increment:为long,short或者int类型主键生成唯一标识。只有在没有其他进程往同一张表中插入数据时才能使用。在集群下不能使用!identity:在DB2,MySQL,Microsoft SQL Server,Sybase和HypersonicSQL...
阅读全文
Spring组件扫描<context:component-scan/>使用详解
摘要:或@Component@Scope("prototype")public class TreeUtil{.....}如果不想在xml文件中配置bean,我们可以给我们的类加上spring组件注解,然后再配置下spring的扫描器就可以实现bean的自动载入。原理:Spring 2.5引入了更多典型化...
阅读全文
web.xml中contextConfigLocation参数的作用
摘要:contextConfigLocation /WEB-INF/classes/applicationContext-hibernate.xml, /WEB-INF/classes/applicationContext-service.xml, /WEB-...
阅读全文
两个值相等的Integer的==比较问题
摘要:@Test public void testIntegerEqual() { /** -128~127 之外的数**/ Integer tem = 129; Integer tem1 = 129; System.out.println(tem == tem1); // false Sy...
阅读全文
java 获取本机的IP地址
摘要:方法一:这种方式有一定的局限性,在Linux下的执行结果是:本机的IP = xxx/127.0.1.1 (其中xxx是你的计算机名)public void getLocalIPAddress() { try { InetAddress inetAddress = ...
阅读全文
java 替换字符串中的中括号
摘要:正确方式:"[adbdesf]".replaceAll("\\[", "").replaceAll("\\]", "")错误方式:"[adbdesf]".replaceAll("[", "").replaceAll("]", "")"[adbdesf]".replaceAll("\[", "").r...
阅读全文
浙公网安备 33010602011771号