Spring BeanWrapper 用于创建 HTTP 表单数据?
我有一个相对简单的任务要实现,并且想问一下使用 spring BeanWrapper (或另一个有能力的库)是否可以实现这一点。
情况如下: 我有一个 java bean,希望将其转换为 HTTP 表单数据(application/x-www-form-urlencoded)。 Spring 使用 BeanWrapper 进行相反的操作,将表单数据转换为 java beans。因此,我期望一个 Map,其中属性路径作为键,并映射它们相应的值。
提前致谢! 马库斯
I have a relative simple task to achieve, and wanted to ask if this is somehow possible using the spring BeanWrapper (or another capable library).
Situation is as following:
I have a java bean and want it converted into HTTP form data (application/x-www-form-urlencoded). Spring is using the BeanWrapper for the other way round, converting form data into java beans. As result I would expect a Map, with the property paths as keys and their corresponding values mapped.
Thanks in advance!
Markus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
几年前我也遇到过类似的问题 - 我想将 java beans 编组到 xml 并返回,但我找不到一个易于使用且符合要求的库。
我最终开发了自己的 BeanWrapper 和 XML 编组器,并将其全部放入多模块 Maven 项目中。
从那以后我一直在改进它,现在它甚至可以与 spring 框架和 spring-oxm 模块集成:)
现在,除了宣传之外,我认为它对您在 java 到 html 之间的转换方面很有用,所以我建议你看一下 Juffrou。
如果您对其工作原理有任何疑问,我将非常乐意回复。
干杯
卡洛斯
I had a similar problem a few years ago - I wanted to marshall java beans to xml and back and I couldn't find a library that was easy to use and fitted the bill.
I ended up developing my own BeanWrapper and XML marshaller and put it all in a multi module maven project.
I have been improving it ever since and now it can even be integrated with the spring framework and the spring-oxm module :)
Now, publicity aside, I think it can be of good use to you in converting from java to html and back, so I suggest you take a peek at Juffrou.
And if you have any questions regarding how it works, I'll be more than happy to respond.
Cheers
Carlos