随笔分类 - Java EE
摘要:平时使用springMVC在方法中访问session中经常很自然地调用Servlet API。用起来非常直观方便,一直没有多考虑什么。比如这样:@RequestMapping(value = "/logout")public String logout(HttpSession session) { ...
阅读全文
摘要:泛型几乎都用‘E’来表示,写着写着就弄混淆了如下:class GenericArrayProblem { public static void main(String[] args) { // Exception in thread "main" java.lang.ClassCastException: // [Ljava.lang.Object; cannot be cast to [Ljava.lang.String; new PrinterWrapper<String>("abc", new StringPrinter()).prin
阅读全文
摘要:package pac.testin;import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.lang.reflect.Proxy;interface Person { void showCommonAbility();}class Man implements Person { private String name; public Man(String name) { super(); this.name = name; ...
阅读全文
摘要:package pac.testin;import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.lang.reflect.Proxy;interface Subject { void request();}class RealSubject implements Subject { public void request() { System.out.println("Here RealSubject go!!"); }}class userSid...
阅读全文
摘要:代码: BigDecimal d1 = new BigDecimal(666666); BigDecimal rate = new BigDecimal(0.00876 * 3); BigDecimal tax = new BigDecimal(1274.23); System.out.println(d1.multiply(rate).add(d1).subtract(tax).setScale(2, RoundingMode.HALF_UP));java.math.RoundingMode下七种方式:RO...
阅读全文
摘要:易变业务用Script编写import javax.script.ScriptEngine;import javax.script.ScriptEngineManager;import javax.script.Bindings;import javax.script.ScriptContext;import javax.script.Invocable;import javax.script.ScriptException; ScriptEngine engine = new ScriptEngineManager() .getEngineByNa...
阅读全文
摘要:1 String keyStr = "SPARTAGO"; 2 String data = "这也是斯巴达"; 3 4 SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); 5 DESKeySpec keySpec = new DESKeySpec(keyStr.getBytes()); 6 Key key = keyFactory.generateSecret(keySpec); 7 8 Algo...
阅读全文
摘要:필요한 jar package(http://commons.apache.org)betwixt API 참고:http://commons.apache.org/betwixt/betwixt-0.8/docs/apidocs/index.htmlcommons-beanutils-1.8.3.jar commons-betwixt-0.8.jar commons-collections-3.2.1.jar commons-digester-2.1.jar commons-logging-1.1.1.jarpackage test;import java.beans.Introspecti
阅读全文
浙公网安备 33010602011771号