English 中文(简体)
如何配置 Web. xml 用于多个端点应用程序?
原标题:How do I configure the web.xml for multiple restlet applications?
  • 时间:2012-05-21 19:37:51
  •  标签:
  • restlet

我想创建一个服务器, 以作为一堆杂货箱应用程序的容器。 我做了一个杂货箱应用程序的服务器, 但我不明白如何修改 Web. xml 以适应许多应用程序 。 下面是 Web. xml 的单个杂货箱 : ( 从“ 恢复行动 MEAP ” 中几乎逐字读取 ) :

<?xml version="1.0" encoding="UTF-8"?>
...
<display-name>Servlet engine as a container of Restlet applications</display-name>
<servlet>
<servlet-name>CompanyServerApplication</servlet-name>
<servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
<init-param>
  <param-name>org.restlet.application</param-name>
  <param-value>server.CompanyServerApplication</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>CompanyServerApplication</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
最佳回答

简单地在您的 web.xml 中添加额外的 块。 例如,我得到了单独的 restlet 应用程序, 用于用户请求和管理员请求。 我的 Web.xml 看起来像这个:

<!-- user servlet -->
<servlet>
  <servlet-name>user</servlet-name>
  <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
  <init-param>
    <param-name>org.restlet.application</param-name>
    <param-value>com.myapp.server.resource.user.UserApplication</param-value>
  </init-param>
  <init-param>
    <param-name>org.restlet.clients</param-name>
    <param-value>HTTP HTTPS</param-value>
  </init-param>
</servlet>

<servlet-mapping>
  <servlet-name>user</servlet-name>
  <url-pattern>/user/*</url-pattern>
</servlet-mapping>

<!-- admin servlet -->
<servlet>
  <servlet-name>admin</servlet-name>
  <servlet-class>org.restlet.ext.servlet.ServerServlet</servlet-class>
  <init-param>
    <param-name>org.restlet.application</param-name>
    <param-value>com.myapp.server.resource.admin.AdminApplication</param-value>
  </init-param>
  <init-param>
    <param-name>org.restlet.clients</param-name>
    <param-value>HTTP HTTPS</param-value>
  </init-param>
</servlet>

<servlet-mapping>
  <servlet-name>admin</servlet-name>
  <url-pattern>/admin/*</url-pattern>
</servlet-mapping>
问题回答

暂无回答




相关问题
Log response-time in restlet-based webservice

What is the simplest way to log the response-time for a restlet-based webservice? I want to make sure that our webservice has a reasonable response time. So I want to be able to keep an eye on ...

Running JUnit Tests on a Restlet Router

Using Restlet I have created a router for my Java application. From using curl, I know that each of the different GET, POST & DELETE requests work for each of the URIs and return the correct JSON ...

How do I create an Atom representation with Restlet?

I want to create atom xml representations for my REST resources using Restlet. Should I (can I?) use ROME or just use the Atom extension for Restlet? What s the best way to go about this? Thanks ...

Restlet: Log Stack Trace for All 500 Errors

I d like my Restlet application to log the stack trace for any Resource that generates a 500-series HTTP error (using the Context s Logger). As far as I can tell, this is not the default behavior. In ...

Concatenate JsonRepresentation

How can I concatenate multiple JsonRepresentation Object into one, without building my own string parser? Say I have two JsonRepresentation objects obj1 = {"name":"obj1"}; obj2 = {"name":"obj2"}; ...

Restlet POST using JSON

How do I implement Restlet function which accepts JSON post? And how do I test this using curl? Thanks

Restlet ClientResource Post Chunked Encoding - WCF Unsuported

I m developing a product that will use extensively of Restlet for consume WCF Rest Services. I had created a method to post a XML of a class containing 2 attributes. Restlet post my xml with Transfer-...

热门标签