Java apachecamel的默认路由
我正在使用ApacheCamel。使用XMLDSL,我的意思是Java apachecamel的默认路由,java,apache-camel,dsl,Java,Apache Camel,Dsl,我正在使用ApacheCamel。使用XMLDSL,我的意思是 <rests id="rests" xmlns="http://camel.apache.org/schema/spring"> <rest id="rest-custom"> <get uri="my_method" method=""> <description>...</description>
<rests id="rests" xmlns="http://camel.apache.org/schema/spring">
<rest id="rest-custom">
<get uri="my_method" method="">
<description>...</description>
<param name="..." ... />
<route>
<process ref="..." />
<to uri="..." />
</route>
</get>
<post uri="another_method" method="" >
<description>...</description>
<param name="..." .../>
<route>
<process ref="..." />
<to uri="..." />
</route>
</post>
...
...
...
...
因此,如果我想要新的路线,我只需添加新的
或
,它就可以正常工作
但是现在我想添加一些默认方法。我的意思是,在所有配置的底部都有类似于
和
的东西。所以,如果我的url与列表中的任何一个都不匹配,它将变为默认值,我可以使用自定义处理器处理它(这是我想要的行为)
现在我不知道该怎么做。试图处理404个响应,但仍然没有成功。看起来解决方案应该很简单,但还找不到。我只看到一种可能的默认情况:如果同一功能有多个URL 如果是这种情况,并且您的客户端不希望或无法切换到单个URL,那么您仍然可以在传入请求到达应用程序之前对其使用URL重写
如果您想捕获所有未知URL(错误),我想您应该使用标准的驼峰错误处理(请参阅和),因为这些剩余DSL块在内部转换为标准驼峰路由 终于找到了解决办法
<get uri="/?matchOnUriPrefix=true&bridgeEndpoint=true" method="">
<description>Default GET method</description>
<route>
...
</route>
</get>
默认获取方法
...
参数matchOnUriPrefix=true&bridgeEndpoint=true成功了