Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 如何使用SpringMVC从复选框元素中获取值_Java_Spring - Fatal编程技术网

Java 如何使用SpringMVC从复选框元素中获取值

Java 如何使用SpringMVC从复选框元素中获取值,java,spring,Java,Spring,首先,我承认我是Spring的新手!我尝试的是确定注册我的应用程序的用户类型:3个月用户还是6个月用户!我使用的复选框在我的用户注册模板(视图)中默认未选中。因此,如果未选中,默认情况下,用户将是一个3个月的用户,反之亦然。我不确定如何获取此数据(3个月用户/6个月用户)并将正确的角色发送到我的数据库(模型)。我请求任何和所有帮助或指导: <input id="userrole" type="checkbox" name="role" value="6 month user" th:

首先,我承认我是Spring的新手!我尝试的是确定注册我的应用程序的用户类型:3个月用户还是6个月用户!我使用的复选框在我的用户注册模板(视图)中默认未选中。因此,如果未选中,默认情况下,用户将是一个3个月的用户,反之亦然。我不确定如何获取此数据(3个月用户/6个月用户)并将正确的角色发送到我的数据库(模型)。我请求任何和所有帮助或指导:

   <input id="userrole" type="checkbox" name="role" value="6 month user" th:checked="${flag}" />
                <span>User Role</span>

用户角色
使用 标记以创建复选框。其中userrole是域属性,是一个布尔变量,在声明时设置为false。

表单标记()