Java 未找到Restful中URI为的HTTP请求的映射
在我使用restful json的项目中,我有以下一些文件: web.xml:Java 未找到Restful中URI为的HTTP请求的映射,java,json,spring,rest,Java,Json,Spring,Rest,在我使用restful json的项目中,我有以下一些文件: web.xml: <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/spring/root-context.xml</param-value> </context-param> <!-- Creates the Sprin
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
发生异常,这是日志:
02:12:23.239 [http-bio-9999-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'appServlet' processing GET request for [/restfulspringmvc/maker/doMarker]
02:12:23.239 [http-bio-9999-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /maker/doMarker
02:12:23.240 [http-bio-9999-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/maker/doMarker]
02:12:23.241 [http-bio-9999-exec-3] WARN o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/restfulspringmvc/maker/doMarker] in DispatcherServlet with name 'appServlet'
02:12:23.245 [http-bio-9999-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
如何修复此配置?
非常感谢你 在jersey类中定义请求映射的方式如下:
@Path("/marker")
public class GetLatLongMapMarker {
@GET
@Path("/doMarker")
@Produces("application/json;charset=utf-8")
public String doMap() {
这将导致/[context path]/marker/doMarker,但您正在请求此urlhttp://192.168.1.221:9999/restfulspringmvc/maker/doMarker
因此,将您的请求中的
maker
更改为marker
,您应该能够找到它我已从一个制造商更改为另一个制造商,但其错误相同。似乎是从servlet-context.xml文件中发现的问题
http://192.168.1.221:9999/restfulspringmvc/maker/doMarker
02:12:23.239 [http-bio-9999-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - DispatcherServlet with name 'appServlet' processing GET request for [/restfulspringmvc/maker/doMarker]
02:12:23.239 [http-bio-9999-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Looking up handler method for path /maker/doMarker
02:12:23.240 [http-bio-9999-exec-3] DEBUG o.s.w.s.m.m.a.RequestMappingHandlerMapping - Did not find handler method for [/maker/doMarker]
02:12:23.241 [http-bio-9999-exec-3] WARN o.s.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/restfulspringmvc/maker/doMarker] in DispatcherServlet with name 'appServlet'
02:12:23.245 [http-bio-9999-exec-3] DEBUG o.s.web.servlet.DispatcherServlet - Successfully completed request
@Path("/marker")
public class GetLatLongMapMarker {
@GET
@Path("/doMarker")
@Produces("application/json;charset=utf-8")
public String doMap() {