[Ljava.lang.String;更新复选框的值时

时间:2014-05-06 09:40:50

标签: java hibernate jsp checkbox

我从jsp和hibernate创建了一个web项目,在我身上有一个复选框...插入数据时没有问题但是在更新数据时我在表单的每个第一个复选框中都得到了[Ljava.lang.String并且我的第一个复选框的值不会存储到数据库,但另一个复选框可以正常工作

如何检查数据库中的复选框值?

我的这部分jsp

<td><spring:message code="authorityRight" text="default text" /></td>
<td>:</td>
<td><fieldset id="menu_e">
    <input type="checkbox" name="menu" value="User" class="ceksmenu">User<br />
    <fieldset id="sub_menu_user_e">
    <input type="checkbox" name="sub_menu_user" value="User1" class="ceksmuser">User1
    <input type="checkbox" name="sub_menu_user" value="User2" class="ceksmuser">User2
    <input type="checkbox" name="sub_menu_user" value="User3" class="ceksmuser">User3<br />
    </fieldset>
    <input type="checkbox" name="menu" value="Monitoring" class="ceksmenu">Monitoring<br />
    <fieldset id="sub_menu_monitoring_e">
    <input type="checkbox" name="sub_menu_monitoring" value="Monitoring1" class="ceksmmonit">Monitoring1
    <input type="checkbox" name="sub_menu_monitoring" value="Monitoring2" class="ceksmmonit">Monitoring2
    <input type="checkbox" name="sub_menu_monitoring" value="Monitoring3" class="ceksmmonit">Monitoring3<br />
    </fieldset>
    <input type="checkbox" name="menu" value="Parameter" class="ceksmenu">Parameter<br />
    <fieldset id="sub_menu_parameter_e">
    <input type="checkbox" name="sub_menu_parameter" value="Parameter1" class="ceksmparam">Parameter1
    <input type="checkbox" name="sub_menu_parameter" value="Parameter2" class="ceksmparam">Parameter2
    <input type="checkbox" name="sub_menu_parameter" value="Parameter3" class="ceksmparam">Parameter3</fieldset>
    </fieldset>
    </td>

这是我的javascript

<script type="text/javascript">
$(document).ready(function() {
    $('.update').click(function() {
        var id_update = $(this).attr("id_update");
        var nama_authority = $(this).attr("nama_authority");
        var menu = $('input:checkbox[name=menu]').is(':checked');
        var sub_menu_user = $('input:checkbox[name=sub_menu_user]').is(':checked');
        var sub_menu_monitoring = $('input:checkbox[name=sub_menu_monitoring]').is(':checked');
        var sub_menu_parameter = $('input:checkbox[name=sub_menu_parameter]').is(':checked');

        $('#id_authority_e').val(id_update);
        $('#id_authority_l').val(id_update);
        $('#nama_authority_e').val(nama_authority);
        $('#menu_e').val(menu);
        $('#sub_menu_user_e').val(sub_menu_user);
        $('#sub_menu_monitoring_e').val(sub_menu_monitoring);
        $('#sub_menu_parameter_e').val(sub_menu_parameter);
    });
    $('.delete').click(function() {
       var id_delete = $(this).attr("id_delete");
    $('#id_authority_d').val(id_delete);
    });
    $('#example').dataTable({
    });
  });
</script>

这是我的控制器

public class Operator {

    @RequestMapping(value = "/admin/updateAuthority.html", method = RequestMethod.POST)
    public ModelAndView updateAuthorityUser(ModelMap model, HttpServletRequest request, 
                                            HttpServletResponse response) throws Exception {

        String id_Authority = request.getParameter("id_authority");
        AuthorityUser authorityuser = authorityuserService.get(id_Authority);

        String nama = request.getParameter("nama_authority");
        String[] menu = request.getParameterValues("menu");
        String[] sb_user = request.getParameterValues("sub_menu_user");
        String[] sb_monitor = request.getParameterValues("sub_menu_monitoring");
        String[] sb_parameter = request.getParameterValues("sub_menu_parameter");

        authorityuser.setId_authority(id_Authority);
        authorityuser.setNama_authority(nama);
        authorityuser.setMenu(menu);
        authorityuser.setSub_menu_user(sb_user);
        authorityuser.setSub_menu_monitoring(sb_monitor);
        authorityuser.setSub_menu_parameter(sb_parameter);

        authorityuserService.update(authorityuser);
        model.addAttribute("successUpdate", "true");
        return listAuthorityUser(model);

    }
}

任何帮助都会很愉快:)

0 个答案:

没有答案