骆驼码头http重定向

时间:2018-12-13 09:35:00

标签: apache-camel karaf

我正在将karaf和骆驼一起使用(每个版本均为最新版本)

我尝试公开一个servlet并像这样重定向到www.google.fr

    RouteDefinition routeDefinition2 = from("servlet:google?matchOnUriPrefix=true").id("reverseProxyRoute");
        routeDefinition2
        .to("http://www.google.fr?bridgeEndpoint=true&traceEnabled=true&throwExceptionOnFailure=false&proxyHost=localhost&proxyPort=3128")

路由正确公开,我可以到达servlet,但是当我这样做时:

http://localhost:8181/camel-example-servlet-rest-blueprint/rest/google

显示了google页面,但是当我启动搜索时,我的网址变成了:

http://localhost:8181/search?safe=active&ei=lSYSXMLkIsa1kwWgsIKABg&q=camel+http

所以我找不到404。

如果我手动重写网址以拥有:

http://localhost:8181/camel-example-servlet-rest-blueprint/rest/google/search?safe=active&ei=cCYSXKDKMNG5kwWT77bYDQ&q=camel+http

有效

我的问题是如何告诉我不要删除的路线

camel-example-servlet-rest-blueprint/rest/google/

非常感谢!

1 个答案:

答案 0 :(得分:0)

删除网址部分是 Google页面的行为

搜索表单的HTML代码是

<form ... action="/search" ...

因此,如果您提交表单,您的浏览器将被发送到/search,并且您将从该URL得到响应。

要执行所需的操作,您必须向用户提供自己的搜索页面。该搜索页面会将搜索词提交给您的应用程序,您将需要使用它进行Google搜索,然后将结果返回给用户(在您自己的结果页面上)。