关闭 SelectOneMenu 内部验证
我有一个由列表驱动的 SelectOneMenu,每个列表都包含一个对象值和一个字符串标签以及一个转换器。一切都相当标准。我最初收到验证错误:值无效 由于 equals 方法中的拼写错误而出现错误,但快速搜索如何修复该问题会带来另一个问题:
我的理解是否正确,在这种情况下,会发生什么:
- 在菜单中选择了一个项目。
- 这将向服务器发送一个字符串值。
- 转换器用于将字符串值转换为对象。
- JSF 检查项目列表中是否存在该对象。
- setter 方法称为传递对象。
如果是这样,我可以禁用第 4 步吗?如果值无效,我的转换器将抛出 ConverterException,因此对我来说,第二个列表遍历完全没有必要。
干杯,
巴尼
I have a SelectOneMenu driven by a List, each of which contains an object value and a string label, along with a converter. All fairly standard. I initially got the Validation Error: Value is not valid error because of a typo in the equals method, but a quick search on how to fix that brings up another question:
Am I right in my understanding that, in this scenario, what happens is:
- An item is selected in the menu.
- This sends a string value to the server.
- The converter is used to convert the string value to an object.
- JSF checks that the object exists in the list of items.
- The setter method is called passing the object.
If so, then can I disable step 4? My converter will throw a ConverterException if the value is not valid, so for me this second list traversal is completely unnecessary.
Cheers,
Barney
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是设计使然。这是标准的网站攻击预防措施之一。你无法将其关闭。
只需将 bean 放在视图范围内(这样就不会在每次请求时重新获取它),或者如果它困扰您,则寻找不太安全的 MVC 框架。
This is by design. It's one of the standard website attack preventions. You can't turn it off.
Just put the bean in view scope (so that it won't be refetched on every request, for the case that), or look for a less secure MVC framework if it bothers you.