制作 <s:checkboxlist> 的选项struts2中垂直显示

2022-01-16 00:00:00 java struts2

*我需要我的复选框列表选项垂直显示,而不是默认的水平显示.我在名称模板的 src 文件夹中创建了一个文件夹,并在另一个文件夹中创建了一个名为 vertical-checkbox 的文件夹,其中包含我修改后的 .ftl 文件自定义复选框列表.我无法显示自定义复选框我在 JSP 中的代码是

*I need my check box list option to display vertically instead of the default horizontal display.I have created a folder in my src folder in the name templates and another folder with name vertical-checkbox containing the modified .ftl file of my customized check box list.I am unable to display the customized check box My code in JSP is

  <s:checkboxlist theme="vertical-checkbox" label="Which of the following are states of India"
                            name="states"
                                list="#{'01':'January','02':'February','03':'March','04':'April',
    '05':'May'}"
      />

请指出我哪里出错了.

推荐答案

通常struts2中的struts checkboxlist会横向调整复选框.在大多数应用程序中,我们希望垂直显示复选框(逐行).为了将其对齐为垂直,我们必须执行以下操作

Normally the struts checkboxlist in struts2 diaply the check boxes horizontally. In most of application we want to display the check boxes vertically (line by line). For aligning this as vertical we have to do the following

  1. 你必须在你的 src 文件夹中创建一个目录模板

  1. You have to create a directory template in your src folder

使用您要创建的模板名称创建一个文件夹(垂直复选框)

Create a folder with the name of the template you want to create (vertical-checkbox)

将struts-2.1.6/src/core/src/main/resources/template/simple/checkboxlist.ftl文件复制到该目录下该文件内容如下.在您必须根据需要或喜欢此链接放置
标签之前:http://codeglobe.blogspot.com/2009/09/struts2-align-check-box-vertical.html

Copy the struts-2.1.6/src/core/src/main/resources/template/simple/checkboxlist.ftl file to this directory content of this file is as follows. Before the you have to put a
tag as you want or like this link: http://codeglobe.blogspot.com/2009/09/struts2-align-check-box-vertical.html

<s:checkboxlist list="urllist" name="selectedValues" listKey="id" listValue="descrption" theme="vertical-checkbox"></s:checkboxlist>

这将为您提供一个垂直的复选框列表.唯一的区别是这里你必须指定和你在项目的src文件夹的模板目录中创建的目录相同的主题.

This will give you a vertical check box list. The only difference is that here you have to specify the theme which is same as the directory you have created in the template directory in the src folder of your project.

相关文章