- 浏览: 191641 次
- 性别:
- 来自: 上海
-
最新评论
文章列表
JAXB入门
- 博客分类:
- J2EE/Core Java
引用jaxb是一个读写xml的工具,还可以提供验证,不需要额外的jar
1. XSD sample
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.example.org/draft_2/"
targetNamespace="http://www.example.org/draft_2/">
...
Freemarker使用入门
- 博客分类:
- J2EE/Core Java
引用freemarker是一种模板标记工具,可以做页面静态化,代码生成 http://freemarker.sourceforge.net/
1 pom 依赖
<dependency>
<groupId>freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.8</version>
<scope>compile</scope>
</dependency>
...
引用perforce是种版本管理软件,提供啦完整的java api,可以方便我们做一些客户化开发,官方文档http://www.perforce.com/product/components/apis
1 . pom 依赖
<dependency>
<groupId>com.perforce</groupId>
<artifactId>p4java</artifactId>
<version>2011.1.297684</version>
</dependency>
...
XPath 入门
- 博客分类:
- J2EE/Core Java
引用xpath可以快速定位获取XML文件中指定属性和值,jdk包含拉所有需要的类
1. 帮助类
public class XpathUtil {
private static final Log logger = LogFactory.getLog(XpathUtil.class.getName());
private Document doc;
public XpathUtil(File file) {
DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
domFact ...
1. Maven Dependency
<dependency>
<groupId>com.googlecode.java-diff-utils</groupId>
<artifactId>diffutils</artifactId>
<version>1.2.1</version>
</dependency>
2. Test Class
package com.citi.ocean.metadata.util;
import java.io.File;
imp ...
XSD 入门使用
- 博客分类:
- J2EE/Core Java
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="note" targetNamespace="http://tempuri.org/note.xsd"
elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="note">
...
1. 安装
地址http://www.sonatype.org/nexus/
解压之后先安装服务,每次开机自动启动
引用nexus-2.1.1\bin\jsw\windows-x86-32\install-nexus.bat
然后查看日志,应该自动启动
console-nexus.bat
start-nexus.bat,stop-nexus.bat开始停止脚本
2. 所有maven应用都使用nexus的配置
copy一份settings.xml到C:\Documents and Settings\caiwen\.m2
settings.xml中添加mirror
<mirror> ...
File Demo
- 博客分类:
- J2EE/Core Java
package org.springside.examples.showcase.utilities.io;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.net.URL;
import java.util.ArrayList;
import java ...
引用遇到需要使用java访问微软的sharepoint的webservice, 公司服
务器配置的是NTLM+SSL验证
解决办法:
jdk6支持ntlm和SSL, 同时使用jdk6 webservice做客户端
1 sharepoint wsdl
https://server/_vti_bin/lists.asmx?WSDL
2 使用如下命令生成webservice客户端代码,将会有很多java类生成
wsimport -d ./bin -s ./src -p test.jws.client.ref ./wsdl/citi.sharepoint.wsdl
3 子类化一个Au ...
1 What is Selenium?
引用Selenium automates browsers. That's it. What you do with that power is entirely up to you. Primarily it is for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can (and should!) also be automated ...
TestCode
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.Default ...
1. HttpClient4.1.2 & HtmlUnit2.9 NTLM 验证
private static final String URL = "*******";
@Test
public void testHttpClient4_1_2Auth() throws ClientProtocolException, IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getAuthSchemes().register("nt ...
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientPro ...
package com.wilson.EDecryption;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchAlgorithmException;
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.KeyGene ...
package com.wilson.EDecryption;
import java.io.UnsupportedEncodingException;
import junit.framework.Assert;
import org.apache.commons.codec.binary.Base64;
import org.junit.Test;
public class Base64CoderTest {
public final static String ENCODING = "UTF-8";
@Test
public ...