java - Apache Camel 的默认路由
问题描述
我正在使用 Apache Camel。使用 XML DSL,我的意思是
<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>
...
因此,如果我想要新路线,我将添加新的<get>
或<post>
它工作正常。
但现在我想添加一些DEFAULT方法。我的意思是,类似于<get uri="*">
和<post uri="*">
在所有配置的底部。因此,如果我的网址与列表中的任何网址都不匹配 - 它会转到默认网址,我可以使用自定义处理器处理它(这是我想要的行为)。
目前我不知道,该怎么做。尝试处理 404 响应,但仍然没有成功。看起来解决方案应该很简单,但还找不到。
解决方案
终于找到了解决办法。
<get uri="/?matchOnUriPrefix=true&bridgeEndpoint=true" method="">
<description>Default GET method</description>
<route>
...
</route>
</get>
参数matchOnUriPrefix=true&bridgeEndpoint=true成功了。
推荐阅读
- c++ - 抛出'std :: system_error'what()的实例后调用c ++终止:加入线程时避免资源死锁
- typescript - Typescript IDE自动从dist而不是src导入
- markdown - 如何在 Pelican Markdown 帖子的元数据部分写评论?
- r - R中累积概率质量函数矩阵的快速随机抽样
- android - 我将如何使用 Kotlin 的序列化库反序列化对象列表?
- asp.net-core - T&T 作为 C# 中的参数来自查询
- autodesk-forge - 使用自定义扩展查看器 Autodesk Forge
- flutter - 指定笔画宽度时未连接阿拉伯文本
- javascript - 为什么这个 puppeteer 的异步函数语法?
- php - 如何使用 MySQLi 和 PHP 从 MySQL DB 中获取单行?