随笔分类 -  Java EE

摘要:平时使用springMVC在方法中访问session中经常很自然地调用Servlet API。用起来非常直观方便,一直没有多考虑什么。比如这样:@RequestMapping(value = "/logout")public String logout(HttpSession session) { ... 阅读全文
posted @ 2014-07-17 17:59 Introspector 阅读(46654) 评论(2) 推荐(1)
摘要:泛型几乎都用‘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 阅读全文
posted @ 2013-04-17 15:01 Introspector 阅读(449) 评论(0) 推荐(0)
摘要: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; ... 阅读全文
posted @ 2013-03-26 19:23 Introspector 阅读(177) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2013-03-25 19:04 Introspector 阅读(173) 评论(0) 推荐(0)
摘要:代码: 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... 阅读全文
posted @ 2013-03-24 23:19 Introspector 阅读(232) 评论(0) 推荐(0)
摘要:易变业务用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... 阅读全文
posted @ 2013-03-22 16:09 Introspector 阅读(859) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2012-12-20 14:48 Introspector 阅读(282) 评论(0) 推荐(0)
摘要:필요한 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 阅读全文
posted @ 2012-08-15 15:04 Introspector 阅读(408) 评论(0) 推荐(0)