Jersey - 在 POST 上使用 XML 和 HTML
我想为我的 RESTful Web 服务提供灵活的身份验证方法 - 通过 HTML 表单或 XML。我意识到我可以从 HTML 表单进行 AJAX 调用,但我认为更简单的机制会很有用(尤其是在开发期间)。
如果我用 @Consumes("application/xml","application/x-www-form-urlencoded") 注释我的 SessionResource.createSession() 方法,它将接受两种类型的内容。困难的部分是区分 XML 流和 HTML。
任何指导或想法将不胜感激。
I would like to provide a flexible authentication method for my RESTful webservice - either via a HTML form or XML. I realize that I can make an AJAX call from the HTML form, but I thought a simpler mechanism would be useful (especially during development).
If I annotate my SessionResource.createSession() method with @Consumes("application/xml","application/x-www-form-urlencoded"), it will accept both types of content. The hard part is to differentiate the XML stream from the HTML.
Any guidance or thoughts would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

为什么不执行以下操作:
如果这不能解决您的问题,请查看 @QueryParam,@HeaderParam 和 @FormParam。
此概述也可能对你。
Why not do the following:
In case this does not solve your problem please have a look at @QueryParam, @HeaderParam and @FormParam.
This overview may also be of some use to you.