我正在使用Spring-mvc和Spring hateoas框架编写ReST API。我正在努力创造一个“自我”。链接到具有@pathvariable Map作为参数的方法。我想要为方法允许多个路径变量(并且它可能在将来增长),并且在方法中我试图根据变量的存在或不存在来解决单独的路径。这一切都正常,直到我尝试创建一个自我链接。
我收到了异常
出现意外错误
type =内部服务器错误,状态= 500)。没有发现转换器能够 从类型转换 [@ org.springframework.web.bind.annotation.PathVariable 输入java.util.Map] [java.lang.String中]
这是我的方法
@RequestMapping(value={"/subs","/masterclient/{masterclient}/subs"},
method = RequestMethod.GET)
public List<Jobs> getJobList(
@PathVariable Map<String, String> pathVariables,
@RequestParam(value="count", required = false) int count)
{
if (pathVariables.containsKey("masterclient"))
{
System.out.println("Master Client = " +
pathVariables.get("masterclient"));
}
else
{
System.out.println("No Master Client");
}
//Add a Link to the self here.
List list = new ArrayList<Jobs>();
list.add(linkTo(methodOn(ControllerJobs.class).getJobList(pathVariables, count)).withSelfRel());
return list;
}
异常堆栈跟踪在
下面2016-10-24 15:39:48.821 ERROR 12068 --- [nio-8080-exec-1] .a.c.c.C。[。[。[。c.v.a。[dispatcherServlet]:Servlet.service()for servlet [dispatcherServlet]与path的上下文 [/com.causeway.vixen.api]抛出异常[请求处理失败; 嵌套异常是 org.springframework.core.convert.ConverterNotFoundException:没有 转换器发现能够从类型转换 [@ org.springframework.web.bind.annotation.PathVariable 输入java.util.Map] [java.lang.String]]有根本原因
org.springframework.core.convert.ConverterNotFoundException:没有 转换器发现能够从类型转换 [@ org.springframework.web.bind.annotation.PathVariable 输入java.util.Map] [java.lang.String] at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:313) 〜[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:195) 〜[spring-core-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.hateoas.mvc.AnnotatedParametersParameterAccessor $ BoundMethodParameter.asString(AnnotatedParametersParameterAccessor.java:172) 〜[spring-hateoas-0.20.0.RELEASE.jar:na] at org.springframework.hateoas.mvc.ControllerLinkBuilderFactory.linkTo(ControllerLinkBuilderFactory.java:143) 〜[spring-hateoas-0.20.0.RELEASE.jar:na] at org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo(ControllerLinkBuilder.java:172) 〜[spring-hateoas-0.20.0.RELEASE.jar:na] at com.causeway.vixen.api.application.ControllerJobs.getJobList(ControllerJobs.java:153) 〜[classes /:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)〜[na:1.8.0_102] at sun.reflect.NativeMethodAccessorImpl.invoke(未知来源) 〜[na:1.8.0_102] at sun.reflect.DelegatingMethodAccessorImpl.invoke(未知来源) 〜[na:1.8.0_102] at java.lang.reflect.Method.invoke(Unknown Source) 〜[na:1.8.0_102] at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) 〜[spring-webmvc-4.3.2.RELEASE.jar:4.3.2.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 〜[tomcat-embed-websocket-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 〜[spring-web-4.3.2.RELEASE.jar:4.3.2.RELEASE] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 〜[tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:785) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1425) [tomcat-embed-core-8.5.4.jar:8.5.4] at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-8.5.4.jar:8.5.4] at java.util.concurrent.ThreadPoolExecutor.runWorker(未知来源) [na:1.8.0_102] at java.util.concurrent.ThreadPoolExecutor $ Worker.run(未知来源) [na:1.8.0_102] at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) java.lang.Thread.run上的[tomcat-embed-core-8.5.4.jar:8.5.4](未知 来源)[na:1.8.0_102]