ITeye博客

蚂蚁的精神

mjbb · 共 53 篇文章

java打zip包

public class TestZip { /** * @param args */ public static void main(String[] args) { String name = "a.txt"; String name2 = "b.txt"; File f1 = new File(name); File f2 = new File(name2); List<File> files = new ArrayList<File>(); files.add(f1); files.add(f2); File out = new File("x.zip"); ZipFiles(fil…

2010-10-25 21:32 · Java小技巧 · 评论(0)

HttpClient 登录网页

public class FormLoginDemo { static final String LOGON_SITE = "xxx.xxx.xxx.xxx"; static final int LOGON_PORT = 8080; public static void main(String[] args) throws Exception { HttpClient client = new HttpClient(); // client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT); client.getHostConfig…

2010-10-25 21:26 · 评论(0)

javaMail 创建 Folder

public class CreateFolder { public static void main(String[] args) { CreateFolder createFolder = new CreateFolder(); try { createFolder.createFolder("bbb"); } catch (MessagingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public boolean createFolder(String folderName) th…

2010-10-25 21:16 · Java小技巧 · 评论(0)

SVN 权限配置

(1) svnserve.conf文件, 你需要处理掉4个label的注释, 分别是authz-db和password-db和anon-access和auth-access.需要注意的是, 确保每行前边没有多余的空格, 否则当你访问svn会报错. 另外最好为realm这个label设置一个有意义的名称, 因为svn client连接server时候, 会显示server的realm名称. 同时如果你想让多个repository共用同一组用户账号, 可以将这几个repository的passwd文件指向同一个文件, 可以使用相对路径来指定passwd文件(相对路径是基准是conf目录), 也可…

2010-10-16 08:03 · 代码和软件管理 · 评论(0)

android 中好用的时间工具-DateUtils

DateUtils.isToday(timeMills) ? DateFormat.getTimeFormat(ctx).format(date) : DateFormat.getDateFormt(ctx).format(date);

2010-10-14 11:07 · android · 评论(0)

不要忘了BroadcastReceiver 注册的用法

BroadcastReceiver 是用来接收广播意图的服务组件,最普通的用法是,在androidmanifest.xml中注册相应的Intentfilter 的Action, 但是还有有另外一种方法就是:在代码中注册,一般用个service在后台运行时候,如下 @Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i("sys","start service"); MyReceiver myReceiver = new MyReceiver(); IntentFilter filte…

2010-10-14 10:52 · android · 评论(0)

Contact 联系人中的一些重要信息

首先应该知道联系人的信息都存放在data表中,其中主要的字段 有 _id:每个记录都有一个这样的id minetype_id:数据类型 raw_contact_id:联系人的id-------------》这个信息有个表维护,自动增长 data1:联系人的详细信息 data2~n:对data1的分解描述 data2:主要介绍信息的种类 在需要查找Contact中的详细信息时,需要以下步骤 1.我们首先要得到Contact的Id(比如:具体哪个人的信息) 2.信息的数据类型:minitype_id(比如:我要的是哪个电话的信息,或者是地址的信息) 3.信息的种类:data2(比如:电话可分为:…

2010-10-08 16:26 · android · 评论(0)

spring与hibernate 整合 2

在spring整合Hibernate的时候, 配置文件主要三个: 1.applicationContext-hibernate.xml: ①.配置数据源(c3p0) ②.配置Hibernate的SessionFactory,使用数据源 ③.数据库的事务管理,主要管理②中的sessionFactory, 2.applicationContext-bean.xml 配置整个程序中出现的pojo(Bean) 3.applicationContext.xml:主要配置文件 导入上面的两个配置文件---> <import resource="classpath:applicationContext-b…

2010-03-29 15:14 · spring · 评论(0)

使用spring 解决中文乱码的问题

使用spring 解决中文乱码的问题 在web.xml中使用spring的filter <filter> <filter-name>encoding</filter-name> <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filt…

2010-03-29 15:09 · spring · 评论(0)

struts 1 与spring 2.5整合要点

struts 1 与spring 2.5整合要点: 在整合中要思考的是:怎样才能实例化spring容器.先把spring容器放到web容器中,然后再根据一些方法去提取 1.在web.xml中配置 ①.加载spring 容器 contextConfigLocation /WEB-INF/classes/beans.xml ②.实例化spring 容器 contextLoader org.springframework.web.context.ContextLoaderServlet 0 org.springframework.web.context.ContextLoaderListener …

2010-03-29 15:07 · spring · 评论(0)

spring 与hibernate的整合思想

hibernate 与spring的整合思想: 1.配置LocalSessionFactoryBean注入到spring配置文件中,属性值当地hibernate.cfg.xml 这样就类似把Hibernate中的SessionFactory注入进来了(这部类似注入 数据源) 2.配置HibernateTemplate,注入sessionFactory。 3.配置DaoImpl层,注入HibernateTemplate 4.不要忘了配置事务的传播方式:如果没配置事务传播方式,数据库操作就不会提交 ①.配置事务传播方式的通知 advice ②.配置切面,定义切入点,并使用事务传播方式的通知 po…

2010-03-29 15:03 · struts1 · 评论(0)

在Action中使用ActionErrors

//在Action中我们可以使用ActionErrors来存储错误的信息: //然后到jsp页面中使用<html:Errors>显示出来 ActionErrors errors = new ActionErrors(); errors.add("name",new ActionMessage("用户名不正确",false)); saveErrors(request,response); //上面的name:指定在页面显示的name对应的名字,false代码不用配置文件, // 如果ActionMessage("login.false");这样只有一个参数的时候,就是使用了 //配置文件中的k…

2010-03-22 19:57 · struts1 · 评论(0)

地址栏上中文乱码问题

//在使用文件下载的时候,我们要把文件的中文名字进行编码,因为我们在传输文件的名字的时候经过地址栏的时候,进行了转码,然后再浏览器页面解析的时候就根据utf-8解码,就会出现乱码的问题,所有在传到地址栏之前就要把中文的值的参数进行解码,然后到页面的时候,就会根据utf-8进行转码。 //如: String name = docTemplate.getName() + "." + docTemplate.getExtension(); System.out.println("编码前:模板文件的名字:"+name); //name = URLEncoder.encode(name, "utf-8…

2010-03-22 19:53 · struts1 · 评论(0)

json与js对象的一些对比与区别

文本生成json对象,必须在外面加一对括号。 因为JSON 是 javascript 的一个子集,所以,在javascript 中使用JSON是非常简单的。 js 代码 var myJSONObject = {"bindings": [ {"ircevent": "privmsg", "method": "newuri", "regex": "^http://.*"}, {"ircevent": "privmsg", "method": "deleteuri", "regex": "^delete.*"}, {"ircevent": "privmsg", "method": "randomu…

2010-03-22 19:51 · javascript · 评论(0)

DispatchAction中ActionForm不足的问题

//我们为了少写Action的时候我们使用了DispatchAction,这样就能减少了 Action的配置了,把所有的请求交个一个DispatchAction处理 //但这样就会出现一个多个不同的请求使用同一个DispatchAction中方法,而出现ActionForm里 面的属性不足, //所以解决方法:在一个ActionForm中写出所有请求要用到ActionForm属性,这样也就是说,所 有的Action方法可以使用同一个ActionForm了 //在使用struts1标签时候,希望标签不回显,且jsp页面不报错,那么就设置struts标签中的 value属性的值为空字符串(“”)

2010-03-22 19:48 · Java小技巧 · 评论(0)