我有入站网关,除了带有 2 个参数的 URL。对于测试,只需在浏览器中发送 localhost://my-path/{param1}/{param2}。在 serviceActivatorClass 中,我接受这两个参数,并在验证后我希望浏览器接受诸如 200 OK、404 not find(如果未找到某些内容)、409 冲突、500 Internal Server Error 之类的响应,具体取决于我对这些参数的验证。但我找不到发送这些浏览器标准错误的方法。
根据规范,入站网关默认应发送 200 OK,但我也无法收到。
<int-http:inbound-gateway id="myId"
request-channel="requestChanel"
supported-methods="GET"
path="/my-path/{param1}/{param2}">
<int-http:header name="param1" expression="#pathVariables.param1"/>
<int-http:header name="param2" expression="#pathVariables.param2/>
</int-http:inbound-gateway>
<int:channel id="requestChanel"/>
<int:service-activator input-channel="requestChanel" ref="serviceActivatorClass"/>
如何使服务激活器向浏览器发送标准错误?
最佳答案
在回复消息中设置 HttpHeaders.STATUS_CODE
header 。
关于java - 如何从服务激活器发送自定义响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57360694/