春天的行为很奇怪......这是我的控制器:
@RequestMapping(value="", method=RequestMethod.GET)
public void search(SearchDTO dto) {
System.out.println(dto.testa.contains);
System.out.println(dto.testa.contains.getClass());
System.out.println(dto.testb.contains);
System.out.println(dto.testb.contains.getClass());
}
搜索DTO.java:
public class SearchDTO {
public UUIDListSearchDTO testa;
public UUIDListSearchDTO getTesta() { return testa; }
public void setTesta(UUIDListSearchDTO testa) { this.testa = testa; }
public ListSearchDTO<UUID> testb;
public ListSearchDTO<UUID> getTestb() { return testb; }
public void setTestb(ListSearchDTO<UUID> testb) { this.testb = testb; }
}
ListSearchDTO.java:
public class ListSearchDTO<C> {
public C contains;
public C getContains() { return contains; }
public void setContains(C contains) { this.contains = contains; }
}
UUIDListSearchDTO.java:
public class UUIDListSearchDTO extends ListSearchDTO<UUID> {
}
现在我调用以下 URL:
GET http://localhost:8080/myApp/myController?testa.contains=11111111-1111-1111-1111-111111111111&testb.contains=11111111-1111-1111-1111-111111111111
我得到的输出:
11111111-1111-1111-1111-111111111111
class java.util.UUID
11111111-1111-1111-1111-111111111111
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.UUID
为什么会这样?
顺便说一句:我正在使用 Spring 4.0.0.M3,也许有人可以用 Spring 3 对其进行测试?
堆栈跟踪:
我已经trace
为整个应用程序设置了调试级别。
(异常发生在第 72 行java.lang.ClassCastException: java.lang.String cannot be cast to java.util.UUID
:)
请求网址:http://localhost:8080/copilot/assets?foreignKeys.contains=11112222-3333-4444-5555-66667777