简体   繁体   English

混合HTML和STRUTS2标签

[英]Mixing HTML and STRUTS2 tags

I have a form which has both HMTL tags and struts tags. 我有一个同时具有HMTL标签和struts标签的表单。 I use the HTML tags because of alignment issues with struts tags. 我使用HTML标记是因为struts标记存在对齐问题。

<s:form action = "setNode" name = "processing" method ="POST">



      <script>
      <!--
      createTree(catArray);

      </script>
      <br/>
      <s:radio name="processOption" label="" list="{'Add','Move','Delete'}" ></s:radio>

      <s:textfield name="node" ></s:textfield>

      <s:submit name="Go" value="              Go                " align="center" />
      </s:form>

the createTree function creates a tree form with HTML checkbox input types. createTree函数使用HTML复选框输入类型创建树形表单。

The action triggers a java function. 该动作触发一个Java函数。 How do i see which checkboxes are checked? 我如何查看已选中的复选框?

Bad approach, I'd say. 我会说不好的方法。

First, have you taken a look at the generated html? 首先,您看一下生成的html吗? (generated by struts, at least - if possible also generated by you javascript). (至少由struts生成-如果可能,还由您的javascript生成)。 It's the first thing to do, always. 永远是第一件事。 Can you post it ? 你可以张贴吗?

Second, are you aware of "themes" in struts2 forms ? 其次,您是否知道struts2形式的“主题”? If you are using the default ("xhtml"), the form will be inside a table, and, if you are going to add some non-struts2 elements inside, you must be aware of that - for example, your <br/> tag seems out of place. 如果使用默认值(“ xhtml”),则表单将位于表中,并且如果要在其中添加一些非struts2元素,则必须注意这一点-例如, <br/>标签似乎不合适。

Third, Struts2 tags are always mixed with html tags, that their point. 第三,Struts2标记始终与html标记混合使用,这是它们的重点。 I guess you mean you are mixing input html tags (form elements) generated in javascript with others generated by the struts2 tags. 我想你的意思是您将javascript中生成的输入html标签(表单元素)与struts2标签生成的其他HTML混合在一起。 In general, this is messy, you should try to avoid this. 通常,这很麻烦,您应该尝试避免这种情况。 Even more when your tags are generated by a black-box javascript function as yours (with document.write() I guess). 当您的标签是由像您一样的黑盒javascript函数生成的时document.write()我猜是带有document.write() )。 You should try (except very special scenarios) to generate those checkboxes with struts2. 您应该尝试(非常特殊的情况除外)使用struts2生成这些复选框。

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

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