Curl 我怎样才能偷偷地把我的信息带过泽西,也许是用骡子
因此,我使用的是Mule(3.3.1)和Jersey(1.6)的旧版本-这两个版本都很新,无法升级-并且有一个类似的问题,即HTML表单数据被Curl 我怎样才能偷偷地把我的信息带过泽西,也许是用骡子,curl,java,post,jersey,mule,form-parameter,Curl,Java,Post,Jersey,Mule,Form Parameter,因此,我使用的是Mule(3.3.1)和Jersey(1.6)的旧版本-这两个版本都很新,无法升级-并且有一个类似的问题,即HTML表单数据被@POSTed总是null,但是使用(强制使用非UTF-8字符集)没有区别,我的@FormParam仍然是null <flow name="repo" doc:name="Repository application"> <inbound-endpoint ref="RepositoryInternalEndpoint">
@POST
ed总是null
,但是使用(强制使用非UTF-8字符集)没有区别,我的@FormParam
仍然是null
<flow name="repo" doc:name="Repository application">
<inbound-endpoint ref="RepositoryInternalEndpoint">
<not-filter>
<wildcard-filter pattern="/favicon.ico"/>
</not-filter>
</inbound-endpoint>
<!-- All seems fine at this point -->
<!--<custom-interceptor class="TestInterceptor"/>-->
<!-- Inside the RepositoryService class, @FormParam args are null -->
<jersey:resources doc:name="Repository Service Component">
<component>
<spring-object bean="repositoryService"/>
</component>
</jersey:resources>
</flow>
使用的命令是
curl -X POST -H "content-type: application/x-www-form-urlencoded" -d "o_serviceId=12345y" localhost:8889/my/url
我相信你正被这个长期存在的问题所困扰: 在比较HTTP和Jetty连接器之间的Mule消息有效负载时,我注意到后者的
application/x-www-form-urlencoded
请求实际上是一个空字符串,而前者包含实际的正文
事实上,如果我在jersey:resources
之前添加此选项,则一切正常:
<set-payload
value="#[org.mule.util.StringUtils.join(message.inboundProperties['request.parameters'].entrySet(),'&')]" />
这基本上是从请求参数中重建消息负载。这是一个快速而肮脏的解决方案:它没有正确地重新编码参数,并且假定
Map.Entry.toString()
始终返回key=value
。但是,通过适当的映射到URL编码字符串
转换很容易改进…使用@FormParam
注释的方法的预期内容类型
?您使用了什么curl
命令?这两个命令都添加到了问题中。谢谢。一切看起来都很好,所以看起来像个虫子。您是否可以在最近的Mule上部署您的应用程序,只是为了看看这是否是一个已修复的问题?恐怕不是。这是一个非常混乱、非常庞大的遗留应用程序,在库更新方面有着难以言喻的痛苦。我很想找到一个解决办法,但如果没有办法的话,我认为最简单的选择就是不要使用我想做的事情,我可以更好地控制它。啊,那太糟糕了,很抱歉读到这篇文章。是否在RepositoryInternalEndpoint
中配置了转换器?也许事情搞砸了?这听起来不错,我会在本周晚些时候试一试。效果不错。太好了,谢谢。不会想到把它移到params。
<set-payload
value="#[org.mule.util.StringUtils.join(message.inboundProperties['request.parameters'].entrySet(),'&')]" />