Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/389.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 带有图像struts2的复选框列表_Java_Jquery_Struts2 - Fatal编程技术网

Java 带有图像struts2的复选框列表

Java 带有图像struts2的复选框列表,java,jquery,struts2,Java,Jquery,Struts2,我将尝试在我的复选框列表中添加这样的图像 <s:checkbox name="evento.eve_tarjeta_cred1" id="chkAmex" /> <img alt="10" src="./images/tarjetasCredito/amex.png"> <s:checkbox name="evento.eve_tarjeta_cred2" id="chkCmr" /> <img alt="10" src="./images/tarjet

我将尝试在我的复选框列表中添加这样的图像

<s:checkbox name="evento.eve_tarjeta_cred1" id="chkAmex" />
<img alt="10" src="./images/tarjetasCredito/amex.png">
<s:checkbox name="evento.eve_tarjeta_cred2" id="chkCmr" />
<img alt="10" src="./images/tarjetasCredito/cmr.png">

但我需要在一个字段中传递一个列表,以便将其保存在我的数据库中 “对,错”

我就这样试试

<s:checkboxlist id="chkTarjeta" name="evento.eve_tarjeta_cred" 
        list="{
            '<img alt="10" src="./images/tarjetasCredito/amex.png">',
            '<img alt="10" src="./images/tarjetasCredito/cmr.png">'
                   }"

/>


但它不起作用。帮助错误可能在
中,
''
}"
/>

我不确定Struts2是否会转义这些值;如果会,唯一的机会就是扩展标记。

要在一个字符串行中提交值,请在两个复选框上使用相同的名称,并且您的
事件。eve_tarjeta_cred
变量必须是字符串。 使用
标记为复选框创建图像标签

注意:不提交未选中的复选框(
false
值)

<s:checkboxlist id="chkTarjeta" name="evento.eve_tarjeta_cred" 
  list="{
    '<img alt=&quot;10&quot; src=&quot;./images/tarjetasCredito/amex.png&quot;>',
    '<img alt=&quot;10&quot; src=&quot;./images/tarjetasCredito/cmr.png&quot;>'
  }"
/>

我这样解决了它,在我的JSP中我得到了这个

<label>
  <s:checkbox name="evento.eve_tarjeta_cred" id="chkAmex" />
  <img alt="10" src="./images/tarjetasCredito/amex.png" />
</label>

<label>
  <s:checkbox name="evento.eve_tarjeta_cred" id="chkCmr" />
  <img alt="10" src="./images/tarjetasCredito/cmr.png" />
</label>
要在更新案例中显示它,只需执行以下操作

tarjetas = t1 + "," + t2;
evento.setEve_tarjeta_cred(tarjetas);
eventoservice.RegistraEvento(evento);
String[]tarjetasArray=evento.getEve\u tarjeta\u cred().split(“,”);
for(int i=0;i
开始接受/投票回答您的问题。我在两天前解决了这个问题,就在每次物业名称呼叫(t1、t2、t3等)和我的“行动”中“阶级I@JesusAlvarez:两天前?答案是7月12日。是的,我在另一个项目中还有其他更重要的活动。@JesusAlvarez:你很忙,这是可以理解的。但是你有没有尝试过这个解决方案?你不必为每个复选框设置单独的变量。如果在JSP中使用相同的名称,Struts2将在字符串变量中放置逗号分隔的值。请参阅我的答案,没有标签标签您的图像是不可点击的。
tarjetas = t1 + "," + t2;
evento.setEve_tarjeta_cred(tarjetas);
eventoservice.RegistraEvento(evento);
String[] tarjetasArray = evento.getEve_tarjeta_cred().split(",");
            for (int i = 0; i < tarjetasArray.length; i++) {
                t1 = tarjetasArray[0];
                t2 = tarjetasArray[1];
            }