您好我正在尝试将我的restlet类部署到一个servlet contatiner到tomcat apache服务器。但是,当我部署它时,它无法启动,也就是说发生了严重错误。任何人都可以帮助我吗?
PS。为什么这么少的restlet文档?什么是太少或太复杂......
package com.restletTest;
import org.restlet.Application;
import org.restlet.Restlet;
import org.restlet.routing.Router;
public class FirstStepsApplication extends Application {
/*
* Creates a root Restlet that will handle all incoming calls
*/
@Override
public synchronized Restlet createInboundRoot(){
//Creates a router Restlet that routes each call to a new instance of helloWorldResponse
Router router = new Router(getContext());
//Defines only one route
router.attach("/hello", HelloWorldResource.class);
router.attach("/goodbye", GoodbyeWorldResource.class);
router.attach("/jsonResource" , JSONResource.class);
return router;
}
}
我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>TestServer</display-name>
<!-- Application class name -->
<context-param>
<param-name>org.restlet.application</param-name>
<param-value>
com.restletTest.FirstStepsApplication
</param-value>
</context-param>
<!-- Restlet adapter -->
<servlet>
<servlet-name>RestletServlet</servlet-name>
<servlet-class>
org.restlet.ext.servlet.ServerServlet
</servlet-class>
</servlet>
<!-- Catch all requests -->
<servlet-mapping>
<servlet-name>RestletServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
有任何获得帮助的机会吗?
答案 0 :(得分:0)
不确定这是否能帮助你解决问题,因为我正在为自己尝试这个小库。
首先:您必须已经定义了3个资源类。
第二:在web.xml中,context-param数据应该在servlet数据中。
希望这有帮助。