@RequestParam CustomMap <string,object =“”> map:java.lang.IllegalArgumentException </string,>

时间:2015-03-18 05:58:13

标签: spring-mvc

我试图找到以下代码段的解决方案但是徒劳无功。

所以这是我的代码寻求帮助:test.java

public class TestMap extends HashMap<String, Object> { 

}

@RequestMapping({ "doTest.action", "/"})
public ModelAndView doTest(
        HttpServletRequest request,
        HttpServletResponse response,
        @RequestParam Map<String, Object> map
        ) throws Exception {
     ...
     ...
}

如果我更换线路:

@RequestParam Map<String, Object> map

使用:

@RequestParam TestMap<String, Object> map

我发现了以下异常:

java.lang.IllegalArgumentException: argument type mismatch

HandlerMethod详细信息: 控制器[controller.UserAction] 方法[public org.springframework.web.servlet.ModelAndView controller.UserAction.toTest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,com.demo.tools.TestMap)throws java.lang.Exception] 已解决的论点: [0] [type = org.apache.catalina.connector.RequestFacade] [value=org.apache.catalina.connector.RequestFacade@66de04cd] [1] [type = org.apache.catalina.connector.ResponseFacade] [value=org.apache.catalina.connector.ResponseFacade@7a0d637d] [2] [type = java.util.LinkedHashMap] [value = {}]

org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:216)
org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:900)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:827)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

根本原因

知道为什么吗?

感谢。

0 个答案:

没有答案