Servlets 使用olingo库创建odata服务时,/*以外的Servlet URL模式不起作用
我正在尝试使用ApacheOlingo库版本2.0创建odata服务。 以下是my web.xml中的内容:Servlets 使用olingo库创建odata服务时,/*以外的Servlet URL模式不起作用,servlets,odata,olingo,Servlets,Odata,Olingo,我正在尝试使用ApacheOlingo库版本2.0创建odata服务。 以下是my web.xml中的内容: <servlet> <servlet-name>StudentServlet</servlet-name> <servlet-class>org.apache.olingo.odata2.core.servlet.ODataServlet</servlet-class> <init-param>
<servlet>
<servlet-name>StudentServlet</servlet-name>
<servlet-class>org.apache.olingo.odata2.core.servlet.ODataServlet</servlet-class>
<init-param>
<param-name>org.apache.olingo.odata2.service.factory</param-name>
<param-value>com.opengalaxy.students.MyServiceFactory</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>StudentServlet</servlet-name>
<url-pattern>/Sample/*</url-pattern>
</servlet-mapping>
学生servlet
org.apache.olingo.odata2.core.servlet.ODataServlet
org.apache.olingo.odata2.service.factory
com.opengalaxy.students.MyServiceFactory
1.
学生servlet
/样品/*
通过上面的servlet映射,当我加载URL“localhost:8888/Sample/$metadata”时,我得到以下错误:
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code />
<message xml:lang="en-US">Could not find an entity set or function import for 'Sample'.</message>
</error>
找不到“Sample”的实体集或函数导入。
但是,如果我将web.xml中的servlet映射改为root,即改为“/*”,如下所示:
学生servlet
/*
并加载URL“localhost:8888/$metadata”,它工作正常并加载元数据:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="com.opengalaxy.Students">
<EntityType Name="Student">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="100" />
</EntityType>
<EntityContainer Name="ODataStudentsEntityContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="Students" EntityType="com.opengalaxy.Students.Student" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
请帮我解决这个问题
谢谢,
KeshavAFAIK这是一个应该在较新版本的Olingo中解决的错误。如果它仍然存在,则打开一个问题:
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" Version="1.0">
<edmx:DataServices xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:DataServiceVersion="1.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="com.opengalaxy.Students">
<EntityType Name="Student">
<Key>
<PropertyRef Name="Id" />
</Key>
<Property Name="Id" Type="Edm.Int32" Nullable="false" />
<Property Name="Name" Type="Edm.String" Nullable="false" MaxLength="100" />
</EntityType>
<EntityContainer Name="ODataStudentsEntityContainer" m:IsDefaultEntityContainer="true">
<EntitySet Name="Students" EntityType="com.opengalaxy.Students.Student" />
</EntityContainer>
</Schema>
</edmx:DataServices>
</edmx:Edmx>