简体   繁体   English

如何在Struts 2中呈现没有隐藏字段的复选框

[英]How to render checkbox without hidden field in Struts 2

When we create Struts2 checkbox using below code 当我们使用以下代码创建Struts2复选框时

<s:checkbox name="checkMe" fieldValue="true" label="Check Me for testing"/>

It gives below HTML representation (I am referring to https://www.mkyong.com/struts2/struts-2-scheckbox-checkbox-example/ ) 它提供了以下HTML表示形式(我指的是https://www.mkyong.com/struts2/struts-2-scheckbox-checkbox-example/

<input type="checkbox" name="checkMe" value="true" id="xx_checkMe"/>
<input type="hidden" id="__checkbox_xx_checkMe" name="__checkbox_checkMe" value="true"/>
<label for="resultAction_checkMe" class="checkboxLabel">Check Me for testing</label>

Is there anyway to eliminate creating hidden parameter because it is causing security vulnerability for my application 无论如何,有没有消除创建隐藏参数的方法,因为这会导致我的应用程序出现安全漏洞

It's used a freemarker template checkbox.ftl to generate html output. 它使用了一个免费标记模板checkbox.ftl来生成html输出。 You can copy from the source archive and modify this template, then use template and templateDir attributes to point to the custom template. 您可以从源档案库复制并修改此模板,然后使用templatetemplateDir属性指向自定义模板。

Or use archived template, but you need to add velocity and velocity-tools dependencies. 或使用存档模板,但是您需要添加velocityvelocity-tools依赖关系。

<s:checkbox name="checkme" template="checkbox.vm" templateDir="template/archive"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM