java.lang.ClassCastException: org.restlet.data.Parameter cannot be cast to org.r
Restlet header传参异常:java.lang.ClassCastException: org.restlet.data.Parameter cannot be cast to org.restlet.engine.header 原因: The object returned by Response/Request.getAttributes().get("org.restlet.http.headers") is a Series
, not a Form, which is a Series. Because of type erasure, there is no runtime problem until the Restlet Engine tries to make use of the Parameter you stored and treat it as a Header. private static final String HEADERS_KEY = "org.restlet.http.headers"; ... @SuppressWarnings("unchecked") static Series
getMessageHeaders(Message message) { ConcurrentMap attrs = message.getAttributes(); Series
headers = (Series
) attrs.get(HEADERS_KEY); if (headers == null) { headers = new Series
(Header.class); Series
prev = (Series
) attrs.putIfAbsent(HEADERS_KEY, headers); if (prev != null) { headers = prev; } } return headers; } ... // In some method, what you originally wanted to do: getMessageHeaders(getResponse()).add("Access-Control-Allow-Origin", "*"); //or getRequest()