Java技术

spring3_scheduler 任务调度

Posted on 九月 3rd, 2010 by lichangyu and tagged .
lichangyu 的头像

1.spring 定时任务在执行时会扫描需要定时的程序,此时程序内部不可出现未注入的方法及对象,由于(kof-servlet.xml)Controller只管控制器的注入,所以
会出现messageSource无法注入的错误。
例如:spring国际化问题。

在Controller中:private ReloadableResourceBundleMessageSource messageSource;

@Autowired
public void setMessageSource(final MessageSource messageSource) {

JDK5 timer ScheduledExecutorService

Posted on 八月 26th, 2010 by lichangyu and tagged .
lichangyu 的头像

//定时任务
ScheduledExecutorService executor= Executors.newScheduledThreadPool(5);
executor.schedule(new TimerTask(){

@Override
public void run() {
long time = System.currentTimeMillis();
buffService.removeLastTime(time);
}

},10,TimeUnit.HOURS);//表示多少个小时后执行
 

svn_cleanup_locked

Posted on 八月 18th, 2010 by lichangyu and tagged .
lichangyu 的头像

推荐的方法:
1.备份要提交的目录及文件,备份后直接删除本地的副本;
2.回到上一级目录,执行Cleanup;
3.建立与删除目录同名的目录重新Checkout;
 

spring-quartz配置

Posted on 八月 12th, 2010 by lichangyu and tagged .
lichangyu 的头像

1.spring2.5版本
2.加载jar包quartz-all-1.6.1.jar
3.配置定时quartz.xml文件:放到项目WEB-INF/
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"

对去掉空格或空白符的一些方法

Posted on 八月 9th, 2010 by lichangyu and tagged .
lichangyu 的头像

//1.去掉字符串的空格
String str = "aaa dd cc";
//第一种:
System.out.println(str.replaceAll(" ",""));
//第二种:
System.out.println(str.replaceAll(" +",""));
结果:aaaddcc

//2.替换字符串为特定字符
//第一种:
System.out.println(str.replaceAll(" ","+"));
//第二种:

DES加密小结

Posted on 八月 9th, 2010 by lichangyu and tagged .
lichangyu 的头像

import java.io.ByteArrayOutputStream;
import java.security.Key;
import java.security.MessageDigest;

import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

/**

向上取整,再向小数点前n位取整;向下取整

Posted on 八月 6th, 2010 by lichangyu and tagged .
lichangyu 的头像

1.向上取整,再向小数点前2位取整
double d = 1484.32;
int i1 =10*(int)( Math.Ceiling( d / 10));//1490//向前一位
int i2 = 100 * (int)(Math.Ceiling(d / 100));//1500向前二位
int i3 = 1000 *(int)(Math.Ceiling(d / 1000));//2000向前三位

2.向下取整
int il = (int)Math.floor(d);//1484
 

TOMCAT6 配置 JROCKIT MISSION CONTROL

Posted on 七月 13th, 2010 by lichangyu and tagged .
lichangyu 的头像
TOMCAT 配置 JROCKIT MISSION CONTROL

配置JAVA_HOME,CLASSPATH,PATH等为JROCKIT路径和包,主要是JAVA_HOME,TOMCAT需要使用

然后配置TOMCAT启动参数

CATALINA.BAT中找到

多个对象放到LIST中随机排序

Posted on 五月 31st, 2010 by lichangyu and tagged .
lichangyu 的头像

//把多个对象随机进行排序

  System.out.println("asdf");

  List<TestList> list = new ArrayList<TestList>();

  for(int i = 0;i < 10;i++) {

   TestList tl = new TestList();

   tl.setId(i);

   tl.setName("name"+i);

删除JSP编译后的空行(主要针对wap用户)

Posted on 三月 5th, 2010 by lichangyu and tagged .
lichangyu 的头像

方案1.在Tomcat安装目录/conf/web.xml中找到名叫"jsp"的servlet,添加下面一段代码:

<init-param>
<param-name>trimSpaces</param-name>
<param-value>true</param-value>
</init-param>

添加代码后删除work缓存

方案2.<%@ page trimDirectiveWhitespaces="true" %>每个页面加上,此方法最有效,但是比较麻烦