随笔分类 -  Java

上一页 1 2

Listener 监听Session内的对象
摘要:Listener用于监控Session内的对象,分别是HttpSessionBindingListener与HttpSessionActivationListener。它们的触发时机分别为: HttpSessionBindingListener:当对象被放到Session里时执行valueBound 阅读全文

posted @ 2017-05-02 22:50 AlexGeng 阅读(254) 评论(0) 推荐(0)

Listener 监听对象的属性变化
摘要:Listener用于监听Session、context、Request的属性变化,接口名称格式为xxxAttributeListener,包括HttpSessionAttributeListener、ServletContextAttributeLIstener、ServletRequesAttri 阅读全文

posted @ 2017-04-18 22:29 AlexGeng 阅读(812) 评论(0) 推荐(0)

Listener 监听对象的创建和销毁
摘要:HttpSessionListener、ServletContextListener、ServletRequestListener分别用于控制Session、context、request的创建和销毁。触发时机分别为: HttpSessionListener:监听Session的创建和销毁。创建se 阅读全文

posted @ 2017-04-18 22:19 AlexGeng 阅读(1560) 评论(0) 推荐(0)

Java以UTF-8编码读写文件
摘要:java中文件操作体现了设计模式中的装饰者模式 。 以utf-8编码写入文件: FileOutputStream fos = new FileOutputStream("test.txt"); OutputStreamWriter osw = new OutputStreamWriter(fos, 阅读全文

posted @ 2017-04-09 11:35 AlexGeng 阅读(20655) 评论(0) 推荐(0)

Java中String与byte[]的转换
摘要:String s = "fs123fdsa";//String变量 byte b[] = s.getBytes();//String转换为byte[] String t = new String(b);//bytep[]转换为String 做JAVA经常会碰到中文乱码问题,还有各种编码的问题,特别是 阅读全文

posted @ 2017-04-06 10:10 AlexGeng 阅读(544) 评论(0) 推荐(0)

mybatis example 使用AND 和OR 联合查询
摘要:mybatis example 使用AND 和OR 联合查询 生成代码如下: 阅读全文

posted @ 2017-04-01 11:19 AlexGeng 阅读(11199) 评论(0) 推荐(0)

Unicode编码:保存中文cookie
摘要:中文和英文字符不同,中文属于Unicod字符,在内存中站4个字符,而英文属于ASCII字符,内存中只占2个字符。Cookie中使用Unicode字符时需要对Unicode字符进行编码,否则会乱码。编码使用java.net.URLEncoder类的encode(String str,String en 阅读全文

posted @ 2017-03-30 16:14 AlexGeng 阅读(3430) 评论(0) 推荐(0)

String.format详解(转)
摘要:一、前言 String.format 作为文本处理工具,为我们提供强大而丰富的字符串格式化功能,为了不止步于简单调用 String.format("Hello %s", "John"); ,下面将笔记整理并记录下来。 二、重载方法 三、占位符 占位符完整格式为: %[index$][标识]*[最小宽 阅读全文

posted @ 2016-03-31 10:40 AlexGeng 阅读(2125) 评论(0) 推荐(0)

java 使用 ScriptEngineManager 解析逻辑表达式
摘要:将表达式替换成js使用的文本格式。然后带入eval函数。 阅读全文

posted @ 2016-03-30 17:30 AlexGeng 阅读(10263) 评论(1) 推荐(1)

MyBatis+MySQL 返回插入的主键ID
摘要:需求:使用MyBatis往MySQL数据库中插入一条记录后,需要返回该条记录的自增主键值。 方法:在mapper中指定keyProperty属性,示例如下:  useGeneratedKeys: 取值范围true|false 默认值是:false。 含义:设置是否使用JDBC的getGenereat 阅读全文

posted @ 2016-03-14 17:55 AlexGeng 阅读(17160) 评论(0) 推荐(0)

Eclipse中如何修改SVN的地址
摘要:在SVN服务端的IP更改后,客户端SVN的连接地址可以在Eclipse中进行修改,方法如下: 首先:在Eclipse中选择Windows-> Show View->others 就会出现【SVN资源库/SVN Repositories】,选中后,点击确认; 然后:选中原有的地址,选择【重新定位/Re 阅读全文

posted @ 2016-03-03 14:34 AlexGeng 阅读(9137) 评论(0) 推荐(0)

List的遍历和删除元素
摘要:package test; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class ListExercise { public static void main(String 阅读全文

posted @ 2016-02-15 13:20 AlexGeng 阅读(441) 评论(0) 推荐(0)

java中unicode和中文相互转换
摘要:package test.com.gjob.services; import java.util.Properties; public class Test { public static void main(String[] args) { String s = "简介"; String tt = 阅读全文

posted @ 2016-02-14 17:21 AlexGeng 阅读(4878) 评论(0) 推荐(0)

java replaceall 使用正则表达式替换单等号,不替换其他相关的等号。
摘要:写项目需要将公式配置到数据库中,取出后根据公式规则进行比较,由于公式的等于是用单等号,在java中无法直接使用,故需要将单等号替换成双等号,单又不能影响大于等于以及其他形式。故果断选择正则表达式替换。以此留痕,备用。@org.junit.Test public void test4() ... 阅读全文

posted @ 2016-01-14 11:10 AlexGeng 阅读(2822) 评论(0) 推荐(0)

Java 将图片转二进制再将二进制转成图片
摘要:import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import ja... 阅读全文

posted @ 2015-12-10 14:21 AlexGeng 阅读(21336) 评论(2) 推荐(0)

通过反射查找泛型的属性值
摘要:import java.lang.reflect.Fieldpublic void set(){ List list=new ArrayList(); String name="",value=""; for(T t:list){ C... 阅读全文

posted @ 2015-09-01 10:32 AlexGeng 阅读(2428) 评论(0) 推荐(0)

解決BufferedReader读取UTF-8文件中文乱码(转)
摘要:读取txt文件乱码BufferedReader read = new BufferedReader(new FileReader(new File(filename))); 解决办法:InputStreamReader isr = new InputStreamReader(new FileInp... 阅读全文

posted @ 2015-08-12 14:06 AlexGeng 阅读(1554) 评论(1) 推荐(1)

freemarker XMLGregorianCalendar 转日期
摘要:${m.createdate.toGregorianCalendar().getTime()?string("yyyy-MM-dd")}createdate为XMLGregorianCalendar类型数据;在HTML界面转换为"yyyy-MM-dd"格式数据显示。 阅读全文

posted @ 2015-07-08 20:51 AlexGeng 阅读(722) 评论(0) 推荐(0)

Eclipse中启动tomcat报错java.lang.OutOfMemoryError: PermGen space的解决方法
摘要:有的项目引用了太多的jar包,或者反射生成了太多的类,异或有太多的常量池,就有可能会报java.lang.OutOfMemoryError: PermGen space的错误, 我们知道可以通过jvm参数 -XX:MaxPermSize=256m来配置这部分堆内存的大小。在eclipse中如何配置t... 阅读全文

posted @ 2015-07-01 21:43 AlexGeng 阅读(277) 评论(0) 推荐(0)

上一页 1 2

导航