0
當試圖在用戶資源上調用GET方法時,出現上述錯誤消息:http://localhost:8080/Trempiada/users/12345。 或者只需輸入項目的主要URI:http://localhost:8080/Trempiada。 我有Spring的偵聽器DI和tomcat服務器加載沒有任何異常。 這裏是我的web.xml文件:請求的資源不可用(HTTP 404) - Jersey和Spring集成
<?xml version="1.0" encoding="UTF-8"?>
<!-- This web.xml file is not required when using Servlet 3.0 container,
see implementation details http://jersey.java.net/nonav/documentation/latest/jax-rs.html -->
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<!-- Configure ContextLoaderListener to use JavaConfigWebApplicationContext
instead of the default XmlWebApplicationContext -->
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<!-- Configuration locations must consist of one or more comma- or space-delimited
fully-qualified @Configuration classes -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>org.sharon.trempiada.resources.ResourcesConfiguration org.sharon.trempiada.services.ServicesConfiguration</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>trempiada</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.sharon.trempiada.resources</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>trempiada</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
我應該檢查並在可能是問題?
解決了我的問題。我沒有注意到它是區分大小寫的(Trempiada!= trempiada),我認爲上下文基於webapp名稱,就像在eclipse中的「Servers/Tomcat」標籤下顯示的一樣。 – sharon182