0

Restlet を使い始めたばかりで、バージョン 2.0-M3 を使用しています。Web アプリケーション内で Spring を使用しようとしています。アプリケーション内で URL /hello にアクセスしようとすると、404 エラーが発生します。これが私のコードの一部です:

web.xml

<servlet>
    <servlet-name>rest</servlet-name>
        <servlet-class>
            org.restlet.ext.spring.SpringServerServlet
        </servlet-class>
        <init-param>
        <param-name>org.restlet.component</param-name>
            <param-value>helloComponent</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

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

サーバーリソース:

public class MyResource extends ServerResource {
@Get
public String getResource()  {
    return "Hello World!";
}
}

applicationContext.xml

<bean id="helloComponent" class="org.restlet.ext.spring.SpringComponent">
    <property name="defaultTarget" ref="helloAppliction" />
</bean>

<bean id="helloAppliction" class="MyApplication">
    <property name="root" ref="router" />
</bean>

<!--  Define the router -->
<bean name="router" class="org.restlet.ext.spring.SpringBeanRouter"/>

<!-- Define all the routes -->
<bean name="/hello" id="helloResource" class="MyServerResource" scope="prototype" autowire="byName" />

ログのエラー メッセージは次のとおりです。

Oct 12, 2013 11:34:59 PM org.restlet.engine.log.LogFilter afterHandle
INFO: 2013-10-12        23:34:59        127.0.0.1       -       127.0.0.1       8080    GET     /mywebapp/hello  -       404     330     -       1       http:
//localhost:8080        Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0    -

あなたが何か間違っていると思うなら、誰かが私に言うことができますか?

ありがとう!エリック

4

1 に答える 1

0

Restletのディスカッションボードにも投稿したと思いますか?私はそこで私がしたのと同じように答えます。

「/hello」パスをルーターに接続しません。ルーターにはルートがないため、常に 404 が返されます。

于 2013-10-30T10:46:05.240 に答える