Java

List 与 null 的故事

把 null 加到 list里会怎么样? List<String> list = new ArrayList<String>(); list.add(null); list.add(null); print(list.size()); //将打印:2 list.remove(null); print(list.size()); //将打印:1 随贴附送“清除null”的java方法 static <T> List<T> getNonNullElements(List<T> list){ List<T> resultList = new ArrayList<T>(); for(T t: list){ if(t != null){ resultList.add(t); } } return resultList; }

开源框架的出错信息经常会有误导性

很多开源框架,包括高质量的hibernate, spring等,有时给出的出错信息都会有误导性。 错误实际是在A部分,框架却把错报在B部分。 这种情况下,你可以试着把你的改动先减到最低,测一下;再逐渐一步一步加回来,加一步,测一步。这样就可以定位到出错的原因

wsimport 产生莫名奇妙的@XmlElementRefs

如果wsimport帮你生成的class中没有firstName, lastName, middleName等正常的成员变量名,而是生成下面这样的东西: @XmlElementRefs({ @XmlElementRef(name = "middle-name", type = JAXBElement.class), @XmlElementRef(name = "last-name", type = JAXBElement.class), @XmlElementRef(name = "first-name", type = JAXBElement.class), }) protected List<JAXBElement<? extends Serializable>> content; 那原因就是:  你的WSDL中使用了重复的Element Name "It appears to be due to the same element name of PublicationReferenceType in different namespaces" http://forums.epo.org/open-patent-services-and-publication-server-web-service/topic815.html

查看JDK附带的jax-ws版本

执行“wsimport -version” 即可 结果类似于这个样子:“JAX-WS RI 2.1.6 in JDK 6” 你可能想知道RI是什么意思。看下文: The Reference Implementation of JAX-WS is developed as an open source project and is part of project GlassFish, an open source Java EE application server. It is called JAX-WS RI.

Java API for XML Web Services (jax-ws)的正式定义

官方网站没有定义,还得找wikipedia帮忙 http://en.wikipedia.org/wiki/Java_API_for_XML_Web_Services From Wikipedia, the free encyclopedia The Java API for XML Web Services (JAX-WS) is a Java programming language API for creating web services. It is part of the Java EE platform from Sun Microsystems. Like the other Java EE APIs, JAX-WS uses annotations, introduced in Java SE 5, to simplify the development and …

Java API for XML Web Services (jax-ws)的正式定义 Read More »

如果两个SOAP Web Service共享对象,要注意naming space问题

假设你有两个基于SOAP的web service, 一个叫  FooService, 另一个叫BarService 且这两个Service都使用 HelloBean作为web method的参数或方法值 而且你还希望你的客户只使用一套stub,也就是说客户端只有一个HelloBean.class 那么你就要让这两个web service使用同样的命名空间。否则,在下列这种情况下你会遇到异常: HelloBean bean = fooService.getHelloBean(); barService.saveHelloBean(bean); //JAXB会报命名空间异常,因为fooService产生的bean跟saveHelloBean()所需的bean在命名空间上不一样。    

要在tomcat前面放个apache吗?

转自 http://wiki.apache.org/tomcat/FAQ/Connectors#Q3 Why should I integrate Apache with Tomcat? (or not) There are many reasons to integrate Tomcat with Apache. And there are reasons why it should not be done too. Needless to say, everyone will disagree with the opinions here. With the performance of Tomcat 5 and 6, performance reasons become harder to justify. …

要在tomcat前面放个apache吗? Read More »

MIME邮件格式的定义在 RFC5322中

http://tools.ietf.org/html/rfc5322 3.4. Address Specification    Addresses occur in several message header fields to indicate senders    and recipients of messages.  An address may either be an individual    mailbox, or a group of mailboxes.    address         =   mailbox / group    mailbox         =   name-addr / addr-spec    name-addr       =   [display-name] angle-addr    angle-addr      =   [CFWS] …

MIME邮件格式的定义在 RFC5322中 Read More »