Struts2中的多个提交按钮问题
尝试在 struts2 应用程序中的单个表单中使用多个提交按钮,但无法工作。 这是我使用的jsp代码,
<tr>
<td class="button"><input type="submit" value="Import"
name="destinationImport" class="button"></td>
<td class="button"><input type="submit" value="Export"
name="destinationExport" class="button"></td>
</tr>
这里是java部分
private boolean destinationImport;
private boolean destinationExport;
//and the respective setters and getters
,但我确信Struts2类型转换器在将字符串值转换为布尔值时遇到问题 有人知道如何实现这一目标吗?
提前致谢
Trying to work with multiple submit buttons within a single form in struts2 application but not able to work.
here is the jsp code i am using
<tr>
<td class="button"><input type="submit" value="Import"
name="destinationImport" class="button"></td>
<td class="button"><input type="submit" value="Export"
name="destinationExport" class="button"></td>
</tr>
here is the java part
private boolean destinationImport;
private boolean destinationExport;
//and the respective setters and getters
but i am sure is that Struts2 type convertor is having problem converting the String value to boolean
do any one have idea how to achieve this
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
方法: getDestinationExport / setDestinationExport 应该处理字符串,因为您的值:“Export”和“Import”不能直接转换为布尔类型。
如果需要通过内部规则进行转换,请将相应的代码放在setDestinationExport中。像这样的东西:
Methods : getDestinationExport / setDestinationExport should deal with String, since your values: "Export" and "Import" aren't convertible directly to boolean type.
If you need convert it by internal rule, place corresponding code inside setDestinationExport. Something like that:
这种方式应该有效
参考:
http://serpensalbus.com/blog/tricking-struts2-multiple-submit-按钮/
This way should works
Reference:
http://serpensalbus.com/blog/tricking-struts2-multiple-submit-buttons/